From 052903464cb8c42416952ed255fb1eaa3bc0667f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Mon, 30 Jun 2025 21:19:16 -0700 Subject: [PATCH] Increase default chunk size from 1 KiB to 64 KiB 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 60132d6..cce5ca4 100644 --- a/src/core.js +++ b/src/core.js @@ -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(); -- 2.47.3