Repository navigation
Commit a4627d9
committed
stream: buffer single-chunk stream/iter push() writes without a batch entry
Every push() write allocated, before the chunk was buffered, a [chunk]
array, a BatchEntry with a views array, and a FixedByteView; a read of
several buffered writes then validated each into an array of its own and
copied those into the batch it returns. That was most of what a write
costs (192 of 223 bytes for a 16-byte chunk, without pointer compression).
A single-chunk write() or writeSync() now buffers the chunk's
FixedByteView itself, which has the byteLength a BatchEntry has; entries
are told apart by `views`, which a FixedByteView lacks. writev() keeps its
BatchEntry. A read validates the buffered views straight into the batch
it returns, and a pending write is checked without collecting its chunks.
The checks are the same as before.
Allocation per write (16-byte chunks; the consumer reads the buffered
writes as they come):
- writeSync(), falling back to write(): 223 -> 70 bytes
- await write(): 397 -> 246 bytes
- strings (pooled encoding): 315 -> 185 bytes
testBufferedEntriesReadTogether checks that single-chunk and batch writes
read together are delivered in order, and that a view resized among them
rejects the read. It also passes before this change.
Assisted-by: OpenCode1 parent 79f7b0c commit a4627d9
3 files changed
Lines changed: 81 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
196 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
197 | 201 | | |
198 | 202 | | |
199 | 203 | | |
200 | | - | |
| 204 | + | |
201 | 205 | | |
202 | 206 | | |
203 | 207 | | |
| |||
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
252 | | - | |
| 256 | + | |
253 | 257 | | |
254 | 258 | | |
255 | 259 | | |
| |||
268 | 272 | | |
269 | 273 | | |
270 | 274 | | |
271 | | - | |
272 | 275 | | |
273 | 276 | | |
274 | 277 | | |
| |||
509 | 512 | | |
510 | 513 | | |
511 | 514 | | |
512 | | - | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
513 | 518 | | |
514 | 519 | | |
515 | 520 | | |
516 | 521 | | |
| 522 | + | |
517 | 523 | | |
518 | 524 | | |
519 | | - | |
520 | | - | |
521 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
522 | 533 | | |
523 | 534 | | |
524 | 535 | | |
| |||
587 | 598 | | |
588 | 599 | | |
589 | 600 | | |
590 | | - | |
| 601 | + | |
591 | 602 | | |
592 | 603 | | |
593 | 604 | | |
| |||
640 | 651 | | |
641 | 652 | | |
642 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
643 | 674 | | |
644 | 675 | | |
645 | 676 | | |
| |||
663 | 694 | | |
664 | 695 | | |
665 | 696 | | |
666 | | - | |
| 697 | + | |
667 | 698 | | |
668 | 699 | | |
669 | | - | |
| 700 | + | |
670 | 701 | | |
671 | 702 | | |
672 | | - | |
| 703 | + | |
673 | 704 | | |
674 | 705 | | |
675 | 706 | | |
676 | | - | |
| 707 | + | |
677 | 708 | | |
678 | | - | |
| 709 | + | |
679 | 710 | | |
680 | 711 | | |
681 | | - | |
| 712 | + | |
682 | 713 | | |
683 | 714 | | |
684 | 715 | | |
685 | | - | |
686 | | - | |
| 716 | + | |
687 | 717 | | |
688 | 718 | | |
689 | 719 | | |
690 | | - | |
691 | | - | |
| 720 | + | |
692 | 721 | | |
693 | 722 | | |
694 | 723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1070 | 1070 | | |
1071 | 1071 | | |
1072 | 1072 | | |
| 1073 | + | |
1073 | 1074 | | |
1074 | 1075 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
45 | 76 | | |
46 | 77 | | |
47 | 78 | | |
| |||
336 | 367 | | |
337 | 368 | | |
338 | 369 | | |
| 370 | + | |
339 | 371 | | |
340 | 372 | | |
341 | 373 | | |
| |||
0 commit comments