Skip to content

perf(io): size positioned reads from their offset - #2016

Open
toprameen wants to merge 2 commits into
bendlang:mainfrom
toprameen:size-positioned-read-buffers
Open

toprameen wants to merge 2 commits into
bendlang:mainfrom
toprameen:size-positioned-read-buffers

Conversation

@toprameen

Copy link
Copy Markdown
Contributor

File.read_at still uses the whole regular-file size for its initial JS buffer hint, even when its offset leaves only a small tail. Reading the final five bytes of a 1 GiB sparse file with a 1 GiB cap therefore allocates a 1 GiB buffer.

The reader now subtracts the known offset from the size hint while retaining the 64 KiB floor and existing growth loop. The same read starts with 64 KiB and returns the same bytes. Sequential and line reads retain their existing sizing rules.

The extended cap fixture tests repeated positioned tail reads. On local macOS, the unchanged source CLI, compiled CLI and emitted Bun/Node exceed its five-second alarm; the patch passes all four, and native C passes before and after. Neighboring file fixtures and offset/EOF/cursor checks pass. Repository gate: 54/54; strict TypeScript reports the same seven baseline diagnostics.

@toprameen
toprameen marked this pull request as ready for review November 2, 2026 19:57
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