Skip to content

perf(io): bound initial sequential read buffers - #2346

Open
toprameen wants to merge 1 commit into
bendlang:mainfrom
toprameen:bound-sequential-read-buffers
Open

toprameen wants to merge 1 commit into
bendlang:mainfrom
toprameen:bound-sequential-read-buffers

Conversation

@toprameen

Copy link
Copy Markdown
Contributor

Sequential JavaScript reads can allocate a buffer based on the full file size even after the cursor reaches EOF. Large estimates now start with a smaller buffer and grow to the saved estimate only after that first buffer fills.

With a 1 MiB cap at EOF, the initial buffer drops to 64 KiB. In paired macOS runs, repeated EOF reads took 84% less time on Bun and 53% less time on Node. Existing file-read fixtures passed.

@toprameen
toprameen marked this pull request as ready for review November 24, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant