1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00
denoland-deno/ext
Nathan Whitaker 930ccf928a
perf(ext/http): Reduce size of ResponseBytesInner (#24840)
I noticed
[`set_response_body`](ce42f82b5a/ext/http/service.rs (L439-L443))
was unexpectedly hot in profiles, with most of the time being spent in
`memmove`.

It turns out that `ResponseBytesInner` was _massive_ (5624 bytes), so
every time we moved a `ResponseBytesInner` (for instance in
`set_response_body`) we were doing a >5kb memmove, which adds up pretty
quickly.

This PR boxes the two larger variants (the compression streams),
shrinking `ResponseBytesInner` to a reasonable 48 bytes.

---
  Benchmarked with a simple hello world server:
```ts
// hello-server.ts
Deno.serve((_req) => {
  return new Response("Hello world");
});
// run with `deno run -A hello-server.ts`
// in separate terminal `wrk -d 10s http://127.0.0.1:8000`
```

Main:
```
Running 10s test @ http://127.0.0.1:8000/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    53.39us    9.53us   0.98ms   92.78%
    Req/Sec    86.57k     3.56k   91.58k    91.09%
  1739319 requests in 10.10s, 248.81MB read
Requests/sec: 172220.92
Transfer/sec:     24.64MB
```

This PR:
```
Running 10s test @ http://127.0.0.1:8000/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    45.44us    8.49us   0.91ms   90.04%
    Req/Sec   100.65k     2.26k  102.65k    96.53%
  2022296 requests in 10.10s, 289.29MB read
Requests/sec: 200226.20
Transfer/sec:     28.64MB
```

So a nice ~15% bump. (With response body compression, the gain is ~10%
for gzip and neutral for brotli)
2024-08-02 00:30:26 +00:00
..
broadcast_channel chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
cache chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
canvas chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
console fix(ext/console): render properties of Intl.Locale (#24827) 2024-08-01 09:45:05 -07:00
cron chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
crypto chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
fetch fix(ext/fetch): use correct ALPN to socks5 proxies (#24817) 2024-08-01 00:44:03 +02:00
ffi chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
fs chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
http perf(ext/http): Reduce size of ResponseBytesInner (#24840) 2024-08-02 00:30:26 +00:00
io chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
kv chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
napi chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
net chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
node fix: regressions around Error.prepareStackTrace (#24839) 2024-08-01 22:15:20 +00:00
node_resolver feat: upgrade V8 to 12.8 (#24693) 2024-07-31 23:22:34 +00:00
tls chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
url chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
web chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
webgpu fix(ext/webgpu): assign missing constants property of shader about GPUDevice.createRenderPipeline[Async] (#24803) 2024-08-01 11:19:25 -07:00
webidl chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
websocket chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00
webstorage chore: forward v1.45.5 release commit to main (#24818) 2024-07-31 15:14:27 -07:00