1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-27 16:10:57 -05:00
denoland-deno/ext/web
Matt Mastracci 084eafe508
perf(ext/http): recover memory for serve and optimize AbortController (#23559)
Max rps without a signal is unchanged, however we can drastically reduce
memory usage by not creating the signal until needed, and we can
optimize the rps in the case where the signal is created.

With a quick memory benchmark, it looks like this helps pretty
drastically with # of GCs when benchmarking w/wrk:

 - 1.42.4: 1763
 - canary: 1093
 - this patch: 874

This branch:
```

Running 10s test @ http://localhost:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    87.33us  439.95us  20.68ms   99.67%
    Req/Sec    66.70k     6.39k   74.11k    83.66%
  1340255 requests in 10.10s, 191.73MB read
Requests/sec: 132696.90
Transfer/sec:     18.98MB

cpu: Apple M2 Pro
runtime: deno 1.43.0 (aarch64-apple-darwin)

file:///Users/matt/Documents/scripts/bench_request.js
benchmark                                      time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------------------------- -----------------------------
newRequest                                     986.5 ns/iter   1,013,682.6    (878.2 ns … 1.18 µs) 1.01 µs 1.18 µs 1.18 µs
newAbortController                                18 ns/iter  55,541,104.1    (15.6 ns … 42.62 ns) 17.71 ns 25.05 ns 26.27 ns
newAbortControllerSignal                       18.66 ns/iter  53,578,966.7   (16.49 ns … 32.16 ns) 18.71 ns 25.67 ns 26.39 ns
newAbortControllerSignalOnAbort               106.49 ns/iter   9,390,164.9  (97.87 ns … 120.61 ns) 108.6 ns 114.24 ns 115.89 ns
newAbortControllerSignalAddEventListener       86.92 ns/iter  11,504,880.2  (81.88 ns … 103.15 ns) 90 ns 98.28 ns 99.55 ns
newAbortControllerSignalOnAbortNoListener       3.01 µs/iter     331,964.4      (2.97 µs … 3.1 µs) 3.06 µs 3.1 µs 3.1 µs
newAbortControllerSignalOnAbortAbort            3.26 µs/iter     306,662.6     (3.22 µs … 3.36 µs) 3.27 µs 3.36 µs 3.36 µs


```

Latest canary:
```
Running 10s test @ http://localhost:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    72.86us   71.23us   4.47ms   99.05%
    Req/Sec    64.66k     5.54k   72.48k    82.18%
  1299015 requests in 10.10s, 185.83MB read
Requests/sec: 128616.02
Transfer/sec:     18.40MB


cpu: Apple M2 Pro
runtime: deno 1.43.0+bc4aa5f (aarch64-apple-darwin)

file:///Users/matt/Documents/scripts/bench_request.js
benchmark                                      time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------------------------- -----------------------------
newRequest                                      1.25 µs/iter     800,005.2     (1.01 µs … 4.18 µs) 1.16 µs 4.18 µs 4.18 µs
newAbortController                             18.56 ns/iter  53,868,204.3   (16.04 ns … 38.73 ns) 18.38 ns 26.1 ns 26.63 ns
newAbortControllerSignal                       18.72 ns/iter  53,430,746.1   (16.13 ns … 36.71 ns) 18.71 ns 26.19 ns 26.98 ns
newAbortControllerSignalOnAbort               193.91 ns/iter   5,156,992.4 (184.25 ns … 211.41 ns) 194.96 ns 207.87 ns 209.4 ns
newAbortControllerSignalAddEventListener      171.45 ns/iter   5,832,569.2    (153 ns … 182.03 ns) 176.17 ns 180.75 ns 181.05 ns
newAbortControllerSignalOnAbortNoListener       3.07 µs/iter     326,263.3     (2.98 µs … 3.17 µs) 3.08 µs 3.17 µs 3.17 µs
newAbortControllerSignalOnAbortAbort            3.32 µs/iter     301,344.6      (3.29 µs … 3.4 µs) 3.33 µs 3.4 µs 3.4 µs
```
2024-04-25 14:52:24 -04:00
..
benches perf(cli): use new deno_core timers (#22569) 2024-03-01 11:15:18 -07:00
00_infra.js fix: Support Symbol.metadata (#22282) 2024-02-06 14:57:25 +01:00
01_dom_exception.js refactor: use core.ensureFastOps() (#21888) 2024-01-10 15:37:25 -07:00
01_mimesniff.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
02_event.js chore: upgrade deno_core to 0.272.0 (#23022) 2024-03-21 13:57:32 -07:00
02_structured_clone.js fix: Float16Array support (#23512) 2024-04-23 22:54:19 +02:00
02_timers.js perf(cli): use new deno_core timers (#22569) 2024-03-01 11:15:18 -07:00
03_abort_signal.js perf(ext/http): recover memory for serve and optimize AbortController (#23559) 2024-04-25 14:52:24 -04:00
04_global_interfaces.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
05_base64.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
06_streams.js fix: Float16Array support (#23512) 2024-04-23 22:54:19 +02:00
06_streams_types.d.ts chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
08_text_encoding.js refactor: migrate extensions to virtual ops module (#22135) 2024-01-26 23:46:46 +01:00
09_file.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
10_filereader.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
12_location.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
13_message_port.js fix(ext/node): panic on 'worker_threads.receiveMessageOnPort' (#23386) 2024-04-16 01:06:39 +02:00
14_compression.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
15_performance.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
16_image_data.js refactor(ext/web): use relative specifiers (#23024) 2024-03-22 17:21:05 +01:00
blob.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
Cargo.toml 1.43.0 (#23549) 2024-04-25 15:14:26 +05:30
compression.rs fix(ext/web): Prevent (De-)CompressionStream resource leak on stream cancellation (#21199) 2024-02-13 21:45:23 +00:00
internal.d.ts fix(ext/node) implement receiveMessageOnPort for node:worker_threads (#22766) 2024-03-11 00:23:06 +01:00
lib.deno_web.d.ts fix(ext/web): Fix structuredClone Web API type declaration (any -> generic) (#22968) 2024-03-25 22:44:49 +01:00
lib.rs fix(ext/node): support MessagePort in WorkerOptions.workerData (#22950) 2024-03-16 01:59:18 +01:00
message_port.rs fix(ext/node): worker_threads.receiveMessageOnPort doesn't panic (#23406) 2024-04-16 18:41:03 +00:00
README.md Rename extensions/ directory to ext/ (#11643) 2021-08-11 12:27:05 +02:00
stream_resource.rs chore: update to Rust 1.77.2 (#23262) 2024-04-10 22:08:23 +00:00
timers.rs chore: enable clippy unused_async rule (#22834) 2024-03-11 23:48:00 -04:00

deno web

Op crate that implements Event, TextEncoder, TextDecoder and File API (https://w3c.github.io/FileAPI).

Testing for text encoding is done via WPT in cli/.