Proposal for two micro-optimzations in RequestHandler.start function #2604
Description
Basically, I would like to work on two different micro-optimizations to speed up a bit, arround 5% and 10% overall, for the most costly function RequestHandler.start. I would like to gather your feedback before start working on them.
-
Handle most of the keepalive logic outside of the
RequestHandler.start, and leave there only the none happy path - when the keep alive has to be canceled. This will save us to execute a few opcodes and many time syscalls. [1] -
Get rid of the
set_tcp_corkandset_tcp_nodelayoperations and provide an API to be used by the internal layer that guarantees that a code path that touches any TCP configuration sets back the original values, this might be implemented using a context. [2]
I know that I might be missing something that would avoid implementing this two micro-optimizations, hence please feedback will be more than appreciate
[1] https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_protocol.py#L476
[2] https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_protocol.py#L426