Repository navigation
Commit b654075
authored
perf: stop splitting decompressor input into 16 KiB writes (#30)
* perf: stop splitting decompressor input into 16 KiB writes
The split capped WebKit's output chunks, since WebKit inflates a whole input write into one chunk, at about 16 MiB instead of 64 MiB. That only matters for near-1032:1 data such as zip bombs or long runs of zeros, and the size check already rejects an oversized chunk before it reaches the caller. Meanwhile the extra writes slow decompression of incompressible data by up to 2x in Node, Chromium, Firefox and WebKit, and large realistic entries by about 5-10% end to end.
Reads are already at most 64 KiB, the queue's high-water mark, so that remains the bound on each write.
* test: check entry data is read in bounded slices instead of output chunk size
* fix: stop Node 22 reading whole deflated entries into memory
Node before 24.19 counts each chunk written to DecompressionStream as size 1 against a 16 KiB high-water mark, so pipeThrough read an entry's entire compressed data ahead of the reader (nodejs/node#62986). A 64 MiB entry held 64 MiB after reading one chunk.
Feed the decompressor one awaited write at a time instead of using pipeThrough, which bounds read-ahead to a few chunks on every runtime. The decompress-node contract test now checks that an abort reason reaches the reader as the same object, which the upstream error mapping relies on.1 parent d62e0a6 commit b654075
3 files changed
Lines changed: 71 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
| |||
220 | 216 | | |
221 | 217 | | |
222 | 218 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 219 | + | |
230 | 220 | | |
231 | 221 | | |
232 | 222 | | |
| |||
236 | 226 | | |
237 | 227 | | |
238 | 228 | | |
239 | | - | |
| 229 | + | |
| 230 | + | |
240 | 231 | | |
241 | 232 | | |
242 | 233 | | |
| |||
356 | 347 | | |
357 | 348 | | |
358 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
359 | 376 | | |
360 | 377 | | |
361 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1080 | 1080 | | |
1081 | 1081 | | |
1082 | 1082 | | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
1096 | 1087 | | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
1101 | 1119 | | |
1102 | 1120 | | |
1103 | 1121 | | |
| |||
0 commit comments