Repository navigation
Commit 0fb5beb
committed
stream: create the stream/iter share() read reaction once per consumer
share()'s #readAfterPull() created each consumer's afterPull() reaction
lazily with `state.afterPull ??= () => {...}`. Because the arrow function
captures `this` and `state`, V8 allocates its context on every call of
#readAfterPull(), even when afterPull() already exists: about 65 bytes
per read that waits for the source.
afterPull() is now created by #createAfterPull(), so the context is only
allocated when it is.
share() fan-out, async source, two consumers, 16-byte chunks: 2065 ->
1944 bytes allocated per chunk.
Assisted-by: OpenCode1 parent 6108877 commit 0fb5beb
1 file changed
Lines changed: 9 additions & 2 deletions
File tree
- lib/internal/streams/iter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
412 | 420 | | |
413 | 421 | | |
414 | 422 | | |
| |||
426 | 434 | | |
427 | 435 | | |
428 | 436 | | |
429 | | - | |
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
| |||
0 commit comments