Skip to content

fix(dataset): reuse the prefetch window in BlobFile::read - #9330

Open
geruh wants to merge 2 commits into
lance-format:mainfrom
geruh:blob-readall
Open

geruh wants to merge 2 commits into
lance-format:mainfrom
geruh:blob-readall

Conversation

@geruh

@geruh geruh commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

While working on the buffering pr for blobfiles in #9251 I noticed that a header read followed by read() could download the same bytes twice because read() ignored the existing prefetch window and always fetched cursor..size.

So now we reuse the prefetched bytes and only fetch the missing remainder. This avoids the duplicate download while preserving the existing cursor behavior.

do_with_cursor was only used by read(), so the cursor/window bookkeeping is inlined there.

@github-actions github-actions Bot added the bug Something isn't working label Sep 17, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 17, 2026
Joining a partial prefetch window with the fetched tail copied the whole
unread span while the tail was still live, so a header read followed by
read() peaked at about twice the unread payload in Rust. On a 12 MiB blob
with a 1 MiB window that was 24.1 MB of peak allocation for 12.6 MB of
payload, where the plain cursor..size read peaks at 12.6 MB.

The window is now reused only when the tail past it is no larger than the
bytes reused. The transient extra memory then never exceeds the transfer
saved and peak stays under 1.5x the unread span. Larger tails fall back to
the single cursor..size read, which re-fetches at most one window.

Reads above the scheduler's 16 MiB request split still peak at 2x because
the split pieces are joined into one buffer; that is unchanged from before
the prefetch reuse and outside this change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NumG7qmJa1QqiLJe3q2LcS
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 17, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gate recommendation: approve.

The prior memory finding is withdrawn because its allocation measurement did not isolate the pre-existing scheduler behavior. This head keeps complete-window reuse, bounds partial-tail concatenation, and falls back to the prior read for large tails; the focused matrix verifies the three paths, transferred bytes, returned data, and final cursor.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant