Skip to content
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): optimize set_response for small responses #20527

Merged
merged 1 commit into from Sep 16, 2023

Conversation

marcosc90
Copy link
Contributor

@marcosc90 marcosc90 commented Sep 16, 2023

This PR introduces an optimization to set_response to reduce the overhead for responses with a payload size less than 64 bytes. Performance gains are more noticeable when is_request_compressible enters the slow path, ie: -H 'Accept-Encoding: unknown'

Benchmarks

Deno.serve({ port: 3000 }, () => new Response("hello"));
wrk -d 10s --latency -H 'Accept-Encoding: slow' http://127.0.0.1:3000

main

Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    44.72us   28.12us   3.10ms   97.95%
    Req/Sec   112.73k     8.25k  123.66k    91.09%
  2264092 requests in 10.10s, 308.77MB read
Requests/sec: 224187.08
Transfer/sec:     30.57MB

this PR

Running 10s test @ http://127.0.0.1:3000
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    42.91us   20.57us   2.04ms   97.36%
    Req/Sec   116.61k     7.95k  204.81k    88.56%
  2330970 requests in 10.10s, 317.89MB read
Requests/sec: 230806.32
Transfer/sec:     31.48MB

@mmastrac mmastrac enabled auto-merge (squash) September 16, 2023 21:15
Copy link
Member

@mmastrac mmastrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great win. LGTM

@mmastrac mmastrac merged commit 16b7c9c into denoland:main Sep 16, 2023
13 checks passed
@marcosc90 marcosc90 deleted the perf-set-response branch September 16, 2023 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants