A look at our callgraph shows that we are spending some time in ap_add_common_vars() and ap_add_cgi_vars().

Callgraph [final.out]


We can get rid of these with a custom patch to sapi/apache/mod_php5.c. The patch was written by Andrei and you can find it here:

http://www.lerdorf.com/php/sub_env.diff.txt

We can squeeze another 20 requests/second out of the system bringing us to 1120 for this benchmark with that patch. It won't go in the main PHP tree, because it moves functionality from Apache into PHP and there are various packages like ApacheSSL and mod_ssl that patch and change this area of the Apache code, so we have no way of solving this in the general case.

Another idea would be to move request_shutdown out of the content handling phase and closing the connection before we go through and clean up the request.