]> git.ardis.lu - csvio/commitdiff
Increase default chunk size from 1 KiB to 64 KiB
authorArdis Lu <ardisglu@gmail.com>
Tue, 1 Jul 2025 04:19:16 +0000 (21:19 -0700)
committerArdis Lu <ardisglu@gmail.com>
Tue, 1 Jul 2025 04:19:16 +0000 (21:19 -0700)
Benchmarks showed improvements or no change across all tests. Notably, 100MB Read improved from ~13s to ~3s.

The magic value of 64 KiB was selected based on Node.js's default of 16 KiB in similar code [1] and manually testing some multiples over that (Node.js tends to be conservative).

[1] https://github.com/nodejs/node/blob/f69f90d97a30cf9a5f7cbe0260e487ae4d457ed5/lib/internal/fs/promises.js#L317

src/core.js

index 60132d624f154a083b74d8eecced2ec4f961197a..cce5ca4fd19c7d1acb1d54be5d4b8767138e8633 100644 (file)
@@ -44,7 +44,7 @@ export function createFileStream(path) {
 
   return new ReadableStream({
     type: 'bytes',
-    autoAllocateChunkSize: 1024,
+    autoAllocateChunkSize: 65536, // 64 KiB
     async start() {
       handle = await open(path, "r");
       resolveReady();
This page took 0.045649 seconds and 4 git commands to generate.