1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00
denoland-deno/ext
Marcos Casagrande 4960b6659c
perf(ext/streams): optimize async iterator (#20541)
This PR optimizes `ReadableStream` async iterator

### Benchmarks

```js
Deno.bench("Stream - iterator", async () => {
  const stream = new ReadableStream({
    start(controller) {
      controller.enqueue(new Uint8Array([97]));
      controller.enqueue(new Uint8Array([97]));
      controller.close();
    },
  });

  for await (const chunk of stream) {}
});
```

**main**

`2 chunks`
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.4 (x86_64-unknown-linux-gnu)

benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator      12.45 µs/iter      80,295.5   (10.5 µs … 281.12 µs)  12.13 µs  26.71 µs  33.63 µs
```
`20 chunks`

```
benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator      32.99 µs/iter      30,312.2    (28.13 µs … 1.21 ms)   31.8 µs  81.82 µs 179.93 µs
```
---

**this PR**

`2 chunks`
```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.36.4 (x86_64-unknown-linux-gnu)

benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator       9.37 µs/iter     106,700.8   (8.35 µs … 730.71 µs)   9.15 µs  13.12 µs  18.17 µs
```
`20 chunks`
```
benchmark              time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------- -----------------------------
Stream - iterator      16.59 µs/iter      60,270.0    (12.08 µs … 1.37 ms)  15.06 µs  83.03 µs 123.52 µs
```
2023-09-17 15:54:40 +00:00
..
broadcast_channel perf: improve async op santizer speed and accuracy (#20501) 2023-09-16 07:48:31 +02:00
cache feat: support import attributes (#20342) 2023-09-07 09:09:16 -04:00
console chore: forward v1.36.4 to main (#20352) 2023-09-01 18:08:58 +00:00
crypto refactor: rewrite ext/crypto to op2 (#20477) 2023-09-13 17:54:19 +02:00
fetch perf: improve async op santizer speed and accuracy (#20501) 2023-09-16 07:48:31 +02:00
ffi chore: forward v1.36.4 to main (#20352) 2023-09-01 18:08:58 +00:00
fs chore: bump deno_core and cargo update (#20480) 2023-09-13 22:01:31 +00:00
http perf(ext/http): optimize set_response for small responses (#20527) 2023-09-16 15:15:15 -06:00
io refactor: use TaskQueue from deno_unsync (#20485) 2023-09-13 23:36:24 -04:00
kv refactor: rewrite more ops to op2 macro (#20478) 2023-09-14 23:05:18 +02:00
napi chore: forward v1.36.4 to main (#20352) 2023-09-01 18:08:58 +00:00
net chore: bump deno_core and cargo update (#20480) 2023-09-13 22:01:31 +00:00
node feat: Add "deno jupyter" subcommand (#20337) 2023-09-16 02:42:09 +02:00
tls chore: forward v1.36.4 to main (#20352) 2023-09-01 18:08:58 +00:00
url chore: forward v1.36.4 to main (#20352) 2023-09-01 18:08:58 +00:00
web perf(ext/streams): optimize async iterator (#20541) 2023-09-17 15:54:40 +00:00
webidl feat: support import attributes (#20342) 2023-09-07 09:09:16 -04:00
websocket chore: bump deno_core and cargo update (#20480) 2023-09-13 22:01:31 +00:00
webstorage refactor: rewrite ext/io, ext/webstorage ops to op2 (#20461) 2023-09-12 12:42:05 +02:00