Commit fc5b60d
perf(ext/web): add write buffering for FsFile.writable streams
Small buffer writes (e.g. 128 bytes) via `file.writable.getWriter().write()`
were ~100x slower than Node.js because each write immediately dispatched a
syscall through the async op machinery with zero buffering.
Add an opt-in `bufferSize` option to `writableStreamForRid()` and enable it
with a 64KB buffer for `FsFile.writable`. Small chunks are accumulated in a
JS-side buffer and flushed when full or on close. Large chunks (>= bufferSize)
bypass the buffer entirely. The highWaterMark and sizeAlgorithm are also
adjusted to operate on byte length when buffering is enabled.
Only FsFile writable streams are affected — network sockets, stdin, QUIC,
and WebTransport streams remain unbuffered.
Ref: #16667
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 4650330 commit fc5b60d
2 files changed
+59
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
666 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
667 | 672 | | |
668 | 673 | | |
669 | 674 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
1194 | | - | |
| 1194 | + | |
1195 | 1195 | | |
1196 | 1196 | | |
1197 | 1197 | | |
| |||
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1208 | 1220 | | |
1209 | 1221 | | |
1210 | 1222 | | |
1211 | | - | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1212 | 1248 | | |
1213 | 1249 | | |
1214 | 1250 | | |
1215 | 1251 | | |
1216 | 1252 | | |
1217 | | - | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
1218 | 1259 | | |
1219 | 1260 | | |
1220 | 1261 | | |
| 1262 | + | |
1221 | 1263 | | |
1222 | 1264 | | |
1223 | 1265 | | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1224 | 1272 | | |
1225 | 1273 | | |
1226 | 1274 | | |
1227 | 1275 | | |
1228 | 1276 | | |
1229 | | - | |
1230 | | - | |
| 1277 | + | |
| 1278 | + | |
1231 | 1279 | | |
1232 | 1280 | | |
1233 | 1281 | | |
| |||
0 commit comments