-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(ext/http): Object pooling for HttpRecord and HeaderMap #20809
Conversation
Benchmarking on my not very consistent MacBook Air shows around a ~1.5% performance improvement in the minimal benchmark, 121645 req/s vs 120351 req/s on main. |
Note the change to op_http_close to only wait for connections to drain on graceful shutdown: 2d02f4e This Is necessary for the "Throw if disturbed" test to pass which otherwise deadlocks waiting for https://github.com/denoland/deno/blob/main/cli/tests/unit/serve_test.ts#L3323-L3374 EDIT: In #20822 I've added a |
The change to No actual impact as the pool was about to be destroyed anyway, but it's easier to reason about when we ensure Fixed in 908df83. |
Reuse existing existing allocations for HttpRecord and response HeaderMap where possible. At request end used allocations are returned to the pool and the pool and the pool sized to 1/8th the current number of inflight requests. For http1 hyper will reuse the response HeaderMap for the following request on the connection.
908df83
to
ea3f026
Compare
/bench http[minimal,realistic] |
http[minimal]
http[realistic]
start: id: server: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This is slightly slower than baseline but the next PR in the series makes it all faster.
/bench http[minimal,realistic] |
http[minimal]
http[realistic]
start: id: server: |
…dy completion (#20822) Use HttpRecord as response body so requests can be tracked all the way to response body completion. This allows Request properties to be accessed while the response body is streaming. Graceful shutdown now awaits a future instead of async spinning waiting for requests to finish. On the minimal benchmark this refactor improves performance an additional 2% over pooling alone for a net 3% increase over the previous deno main branch. Builds upon #20809 and #20770. --------- Co-authored-by: Matt Mastracci <[email protected]>
Reuse existing existing allocations for HttpRecord and response HeaderMap where possible. At request end used allocations are returned to the pool and the pool and the pool sized to 1/8th the current number of inflight requests. For http1 hyper will reuse the response HeaderMap for the following request on the connection. Builds upon #20770 --------- Co-authored-by: Matt Mastracci <[email protected]>
…dy completion (#20822) Use HttpRecord as response body so requests can be tracked all the way to response body completion. This allows Request properties to be accessed while the response body is streaming. Graceful shutdown now awaits a future instead of async spinning waiting for requests to finish. On the minimal benchmark this refactor improves performance an additional 2% over pooling alone for a net 3% increase over the previous deno main branch. Builds upon #20809 and #20770. --------- Co-authored-by: Matt Mastracci <[email protected]>
…#20809) Reuse existing existing allocations for HttpRecord and response HeaderMap where possible. At request end used allocations are returned to the pool and the pool and the pool sized to 1/8th the current number of inflight requests. For http1 hyper will reuse the response HeaderMap for the following request on the connection. Builds upon denoland#20770 --------- Co-authored-by: Matt Mastracci <[email protected]>
…dy completion (denoland#20822) Use HttpRecord as response body so requests can be tracked all the way to response body completion. This allows Request properties to be accessed while the response body is streaming. Graceful shutdown now awaits a future instead of async spinning waiting for requests to finish. On the minimal benchmark this refactor improves performance an additional 2% over pooling alone for a net 3% increase over the previous deno main branch. Builds upon denoland#20809 and denoland#20770. --------- Co-authored-by: Matt Mastracci <[email protected]>
Reuse existing existing allocations for HttpRecord and response HeaderMap where possible.
At request end used allocations are returned to the pool and the pool and the pool sized to 1/8th the current number of inflight requests.
For http1 hyper will reuse the response HeaderMap for the following request on the connection.
Builds upon #20770