This refactors the Server creation code, to make it easier to create new
Server implementations in the future, and to separate the LibEventServer
code from the main hphp_runtime library.
This defines a new ServerFactory interface, and a ServerFactoryRegistry
which maintains a mapping of server type strings to ServerFactory
objects. The HttpServer code now uses a ServerFactory to create the
m_pageServer, rather than directly creating a LibEventServer object.
This moves the warmup thread logic from LibEventServer to a new
WarmupRequestHandler class. This will allow the logic to work with any
server implementation, since it isn't really specific to LibEventServer.
(Eventually it would perhaps be nice to decouple the worker thread
behavior from the server I/O implementation entirely.)
Make addTakeoverListener() part of the top-level server API, instead of
being specific to LibEventServerWithTakeover. Servers that don't
support socket takeover simply ignore this call.
This will allow future server implementations to support socket
takeover. This also allows us to start making the server creation logic
in HttpServer a bit more generic, since the code can always call
addTakeoverListener() without having to know if it really has a
LibEventServerWithTakeover or some other type of server.
This refactors the RequestHandler code, to decouple RequestHandler
behavior from the Server implementation. The goal is to make it easier
to define additional Server implementations, in addition to just
LibEventServer.
This adds a RequestHandlerFactory function, rather than using a pure
virtual method of the Server class. With the old model, you had to
subclass each server implementation separately for each RequestHandler
type you wanted to use, resulting in NxM classes if you have N server
types and M request handler types.
This also changes the behavior of the RequestHandler class somewhat:
the code now only creates a single RequestHandler per thread, and uses
that object for all request in that thread. Previously the
LibEventServer code would attempt to create a new RequestHandler object
for each request if supportReset() returned true. This was used by
RPCRequestHandler. Now the RPCRequestHandler instead just resets itself
automatically when necessary, without requiring external help from
LibEventServer.
contbuild test runs failed due to git server issues.
I was learning from @jdelong and he said that you should use
double quotes for local includes and angle brackets for library
includes. I asked why our code was the way it was, and he said he wanted
to clean it up. I beat him to it :)
Conflicts:
hphp/runtime/base/server/admin_request_handler.cpp
hphp/runtime/vm/named_entity.h
Before we've jitted the first bit of the TC, having so many
threads leads to a pathological situation: we accept a bunch of
requests (135) and have all of them running in the interpeter,
starving the JIT thread that is trying to make them all go faster.
(Perf record of a machine in this situation shows the vast majority of
the time in dispatchImpl, SrcDB::find, and enterTC). This diff tries
to solve this by limiting the number of threads to the number of cores
for the first N requests.
g++-4.7.1 treats "FOO"bar as a c++-11 literal operator, even
if bar is a macro with an expansion such as "BAR" - so add a space
after the quote (this seems like a bug, and I fixed a bunch of these
a while ago, but we just added a slew of PRI*64 macros which break
under 4.7.1).
Also, it warned that "explicit by-copy capture of 'this' redundant"
for a lambda declared [=, this] - so I removed the this.
We also needed more than the 60 levels of template expansion that was
allowed by the makefile.
Per @mwilliams' suggestion, this is the first stage in a staggered approach to replacing int64 with int64_t. More precisely I inserted "typedef ::int64_t int64;" in util/base.h and dealt with the consequences.
This change is mostly for FB internal organizational reasons.
Building is not effected beyond the fact that the target now
lands in hphp/hhvm/hhvm rather than src/hhvm/hhvm.