fixed some script issues

Summary:
The recipe does not successfully compile fbthrift without included changes
Closes #4

Test Plan: author tested, contbuild, flib

Reviewed By: alikhtarov@fb.com

Subscribers: alikhtarov

FB internal diff: D1607808
Replace IOBufQueue with direct IOBuf management

Summary: This allows us to be smarter about buffer reuse, and eliminates a lot of unnecessary reallocations on partial reads.

Test Plan:
shadow testing shows cpu improvement

Reviewed By: stepan@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1613049

Tasks: 5372756
Simplify McServerSession lifetime management

Summary:
Removes shared_ptr/weak_ptr/set<shared_ptr> stuff.

This is a prerequisite of removing McServerTransaction entirely.
McServerSession knows how many outstanding requests there are, so
it can easily keep track of its own lifetime.  Namely, it destroys
itself (via DelayedDestruction's destroy()) if and only if:

- There are no unreplied requests in the system (equivalent to inFlight_ == 0)
- onClosed() callback has been called, i.e. either someone called session.close()
or any error occurred (protocol error, transport error, etc.)

There's also a modest perf improvement due to removing shared_ptr usage.

Test Plan: unit tests

Reviewed By: stepan@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1613859

Tasks: 5372756
onRequest API changes

Summary:
This is an API change; functional changes have been kept to the necessary minimum.

There are two interface changes in this diff:

- McServerRequestContext is now handed off to the user (via an rvalue reference),
and the user must surrender it back via a static reply() method.
From API design point of view, this ensures that reply is called exactly once
(context's destructor will assert that reply was called, and the context itself
can only be moved around).  It also allows an optimization:
we don't need any heap allocated storage for the context on the server side;
any context storage for async requests is up to the user, and allows for stack only storage
in cases where we can return the reply immediately.

- McRequest is also passed via an rvalue reference. It's up to the user to move it somewhere if async call is necessary. Same performance rationale as above.

Test Plan: unit tests

Reviewed By: andrii@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1613935

Tasks: 5372756
[mcrouter/lib/fibers] addTaskReadyFunc(); expose event base in EventBaseLoopController()

Summary:

Test Plan:
unit tests; shadow testing

Reviewed By: bwatling@fb.com

Subscribers: trunkagent, alikhtarov, meisner, sdmich

FB internal diff: D1528444

Tasks: 4679428
Fix build

Test Plan: build it

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1624795
Report timeout in __mcrouter__.route_handles

Summary: currently it is quite hard to findout the timeout used for particular request. This diff adds "timeout" field to DestinationRoute in __mcrouter__.route_handles request.

Test Plan:
run mcrouter and check "get __mcrouter__.route_handles(get,test)" result

Reviewed By: sdmich@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1626230
Add some missing fields to reply/request; custom reply destructor

Summary:

Test Plan: unit tests

Reviewed By: stepan@fb.com

Subscribers: ps, bmatheny, meisner, trunkagent, alikhtarov

FB internal diff: D1618475

Tasks: 5372756
Remove McServerTransaction

Summary:
Remove heap-allocated McServerTransaction.
This means we no longer keep the request around, and don't bounce McServerTransaction between queues.
In fact for Umbrella protocol, on fast path (singleWrite mode, reply sent from within onRequest callback)
we can do everything using only stack and pre-allocated WriteBuffer.

Note that most of the complexity is due to in-order ASCII protocol (MultiOpParent, blockedReplies, saved key inside request context). We trade off complexity in that case for performance in the out-of-order case.

Test Plan: unit tests

Reviewed By: stepan@fb.com

Subscribers: trunkagent, claudiu, alikhtarov

FB internal diff: D1622709

Tasks: 5372756
Native Umbrella McRequest parsing

Summary:
This diff introduces native code for the McRequest read path in the server.
Before, we would parse umbrella into mc_msg_t, which then would be wrapped in an McRequest.
In addition, the old code had other inefficiencies (entry_list).

Note: folly::Endian produces faster code than ntoh* functions.

Test Plan: unit tests, shadow testing

Reviewed By: stepan@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1624843

Tasks: 5372756
Bugfix: correctly process Umbrella only requests

Summary:
Also add a simply sanity check for server-side Umbrella processing in mcrouter
(two mcrouters in series).

Test Plan:
unit test

Reviewed By: pavlo@fb.com

Subscribers: alikhtarov

FB internal diff: D1638308

Blame Revision: D1624843
Better TKO logging

Summary: For https://github.com/facebook/mcrouter/issues/5 issue. And in general it is a good idea.

Test Plan: mcrouter unit tests, run and check log.

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1637243

Tasks: 5147288
Bugfix/workaround: save McRequest for the lifetime of proxy_request_t object

Summary:
In case of async requests (AllFastest/AllAsync, etc.) we might respond
to the server but still assume that the underlying McRequest's IOBuf stays alive.

The proper fix will be to remove McMsgRef entirely.

Test Plan:
unit tests

Reviewed By: stepan@fb.com

Subscribers: alikhtarov

FB internal diff: D1639461
Add userCtxt and writeSuccess to McServerSession

Summary:
This diff provides a way to store user specific context with each
McServerSession. The diff also allows clients to specify a writeSuccess
callback which is called when all pendingWrites are written out to the
socket.

Test Plan:
unit tests

Reviewed By: alikhtarov@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1638196
Bugfix: keep router_msg.req alive until after mcrouter_send() call

Summary:
mcrouter_send() increfs the request, but temporary dependentMsg() would die
before we called mcrouter_send().

Also fix the catch() statement, since TAsyncServerSocket moved to folly.

Test Plan:
unit tests

Reviewed By: pavlo@fb.com

Subscribers: trunkagent, alikhtarov

FB internal diff: D1639767

Tasks: 5444294
Bugfix: unmark TKO and stop sending probes only if we also recorded success

Summary:
The following scenario is possible:
1) send request A normally
2) send request B normally
3) request A times out, causing us to enter TKO state and start sending probes
4) request B returns normal reply; in the current logic we will _not_ recordSuccess,
but we _will_ stop sending probes, which gets us into an unrecoverable state.

Test Plan:
unit tests

Reviewed By: pavlo@fb.com

Subscribers: alikhtarov

FB internal diff: D1639793

Tasks: 5444294

Blame Revision: D1587681