Skip to content

feat(client): stream parallel downloads to pipes#386

Open
alecthomas wants to merge 3 commits into
mainfrom
aat/parallel-get-stream
Open

feat(client): stream parallel downloads to pipes#386
alecthomas wants to merge 3 commits into
mainfrom
aat/parallel-get-stream

Conversation

@alecthomas

Copy link
Copy Markdown
Collaborator

ParallelGetStream fetches ranged chunks concurrently and reorders
them into a sequential byte stream through an unlinked spill file,
so huge git snapshots (5-10GB) can pipe straight into extraction
with flat RAM. Consumed spill regions are hole-punched (Linux
fallocate, macOS F_PUNCHHOLE) so steady-state disk usage tracks the
gap between download and consumption; a cgo-based layout test guards
the hand-defined darwin struct against SDK drift.

git restore now streams downloads into extraction at every
concurrency, overlapping the two and dropping the full-size temp
file. Pipeline failures report the root cause (first error wins)
rather than closed-pipe or cancellation echoes.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

ParallelGetStream fetches ranged chunks concurrently and reorders
them into a sequential byte stream through an unlinked spill file,
so huge git snapshots (5-10GB) can pipe straight into extraction
with flat RAM. Consumed spill regions are hole-punched (Linux
fallocate, macOS F_PUNCHHOLE) so steady-state disk usage tracks the
gap between download and consumption; a cgo-based layout test guards
the hand-defined darwin struct against SDK drift.

git restore now streams downloads into extraction at every
concurrency, overlapping the two and dropping the full-size temp
file. Pipeline failures report the root cause (first error wins)
rather than closed-pipe or cancellation echoes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alecthomas alecthomas requested a review from a team as a code owner July 9, 2026 03:38
@alecthomas alecthomas requested review from inez and worstell and removed request for a team and inez July 9, 2026 03:38
alecthomas and others added 2 commits July 9, 2026 13:43
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sequential get, ParallelGet, and ParallelGetStream over a 4GiB
object (real snapshots run to several GB) with the CLI's default
8MiB chunks, against the disk backend and a MinIO-backed S3 backend.
s3clienttest now accepts testing.TB so benchmarks can use it.

Chunked gets on the local disk backend are dominated by per-Open
overhead (a synchronous setTTL metadata write per chunk) rather
than I/O; on S3 parallel range gets beat the sequential read.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alecthomas alecthomas force-pushed the aat/parallel-get-stream branch from 81ae113 to c9256e2 Compare July 10, 2026 01:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9256e2b49

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread client/spill.go
// after Close.
func (s *spillBuffer) Close() error {
err := s.f.Close()
if rmErr := os.Remove(s.name); rmErr != nil && !errors.Is(rmErr, os.ErrNotExist) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop unlinking the spill name twice

When the initial os.Remove(f.Name()) in newSpillBuffer succeeds (the normal Unix path), s.name is no longer tied to this open file; it is just a pathname that can be reused before Close runs. In a shared spill directory such as /tmp, another process can create an entry at that observed temp name during a long restore, and this unconditional remove would delete that unrelated file or directory. Track whether the initial unlink failed and only remove on close in that fallback case.

Useful? React with 👍 / 👎.

@alecthomas alecthomas force-pushed the aat/parallel-get-stream branch 2 times, most recently from f4dab42 to c9256e2 Compare July 10, 2026 01:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9256e2b49

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread client/git_test.go
Comment on lines +178 to +180
// newSnapshotRangeServer serves body as a ranged snapshot endpoint, counting
// requests. ServeContent honours Range/If-Range against the ETag, so it
// returns 206 + Content-Range for the chunked requests ParallelGet makes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove top-level test comments

This newly added helper comment is in a top-level test file, and /workspace/cachew/AGENTS.md:21 says, “NEVER add comments to top-level tests.” Leaving this and the other new top-level test comments in this commit violates the repo’s documented review rules, so please remove the comment rather than documenting test helpers here.

Useful? React with 👍 / 👎.

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