You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two low-level reductions in the HTTP parser's per-request work:
- Cache the kOnHeadersComplete, kOnBody and kOnMessageComplete
callback lookups per parser instead of doing an object property Get
on every message. These callbacks are assigned once when the parser
object is created and never change; the cache is cleared in Init()
so re-initialized parsers (direct binding users) stay correct.
- Intern header field-name strings when building the header array.
Field names repeat heavily across requests on a connection, so
interning lets V8's string table return the same string object for
each 'Host', 'User-Agent', etc. instead of allocating a new one per
request. Header values are unique and stay non-interned.
No observable behavior change: header names keep their original case
in rawHeaders and all header/parser tests pass. On a keep-alive server
this is a small but consistent CPU reduction (~2%), measured on both
1-header and 8-header requests.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
0 commit comments