Skip to content

feat(io): range readers and a lazily fetched remote_buffer - #1

Merged
jeandet merged 7 commits into
mainfrom
feat/remote-buffer
Nov 2, 2026
Merged

jeandet merged 7 commits into
mainfrom
feat/remote-buffer

Conversation

@jeandet

@jeandet jeandet commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Adds what a parser needs to read a remote file (S3, HTTP) lazily, fetching each byte at most once. There is no network code: the transport is supplied by the caller.

  • range_reader: a concept for "give me these byte ranges", batched so a transport can fetch them concurrently. The batch fills every range or throws.
  • local_range_reader: a range_reader over a local file that logs every call. It is used to test and measure what a remote reader would be asked for.
  • reserved_region: memory the size of the file, whose pages can't be read until they are written and sealed. Backed by anonymous memory, or by a deleted temp file the OS can page out. Linux, macOS and Windows paths are included; only Linux was compiled locally.
  • remote_buffer: the cache. ensure() widens each read to a read-ahead window, merges what is missing and fetches it in one batch. The first fetch also takes the tail of the file. Unfetched bytes raise in check_present() and fault on a raw read, so they are never read as zeros. It is thread-safe and never calls the reader under its lock. A reader can supply blocking_wait to release an outer lock (Python's GIL) while a thread waits for another thread's fetch.

Used by CDFpp for remote CDF reads (branch feat/remote-reads, opened once this PR is merged and the wrap is bumped).

Tests: 38/38. TestRemoteBuffer also passes under ThreadSanitizer. Fork-based probes check that unsealed pages fault.

🤖 Generated with Claude Code

jeandet and others added 7 commits November 2, 2026 10:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reject reader sizes and read_ahead values that overflow the page math, retry the
first-fetch tail after a failed first fetch, make planning exception-safe, crash
rather than leave a failed batch readable, fetch nothing for empty requests, and
check page ranges without overflow. Tests are stricter: one batch for concurrent
ensures, writes to sealed pages fault, file backing is really file-backed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A thread waiting for another thread's fetch can now release an outer lock (Python's
GIL) that the fetching thread needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ument the exactly-once contract

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…estination count

remote_buffer can take a size its caller already queried (a remote size() is a request),
check_present accepts an empty range at the end of the file, and local_range_reader
rejects mismatched destination counts. Docs: one exception per bullet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeandet
jeandet merged commit 29e4469 into main Nov 2, 2026
10 of 16 checks passed
jeandet added a commit to jeandet/CDFpp that referenced this pull request Nov 2, 2026
cpp_utils is pinned to the head of jeandet/cpp_utils#1 until it merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeandet added a commit to jeandet/CDFpp that referenced this pull request Nov 2, 2026
cpp_utils gains byte-range readers, a reserved memory region and a lazy
remote buffer (jeandet/cpp_utils#1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeandet added a commit to SciQLop/CDFpp that referenced this pull request Nov 2, 2026
cpp_utils gains byte-range readers, a reserved memory region and a lazy
remote buffer (jeandet/cpp_utils#1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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