Avoid extra reconstruction request that returns 416#778
Open
assafvayner wants to merge 3 commits intomainfrom
Open
Avoid extra reconstruction request that returns 416#778assafvayner wants to merge 3 commits intomainfrom
assafvayner wants to merge 3 commits intomainfrom
Conversation
Prefetch tasks are spawned eagerly (at least two in new()), but later tasks don't check whether an earlier task has already discovered the true end of file. This causes the last prefetch to always send an HTTP request that gets a 416 Range Not Satisfiable response. Add a check at the start of each spawned prefetch task: before calling retrieve_file_term_block, read the known_final_byte_position atomic. If a previously completed task has updated it and this task's range starts at or past that position, short-circuit with Ok(None).
hoytak
reviewed
Apr 6, 2026
| // making this request unnecessary. This avoids sending a request that would | ||
| // return a 416 Range Not Satisfiable. | ||
| if prefetch_block_range.start >= known_final_byte_position.load(Ordering::Relaxed) { | ||
| known_final_byte_position.fetch_min(prefetch_block_range.start, Ordering::Relaxed); |
Collaborator
There was a problem hiding this comment.
I think this line is a no-op -- this only triggers if prefetch_block_range.start is already >= known_final_byte_position, which means known_final_byte_position is already at the min of the two.
hoytak
approved these changes
Apr 6, 2026
Collaborator
hoytak
left a comment
There was a problem hiding this comment.
LGTM, with a minor correction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
new()), but later tasks don't check whether an earlier task has already discovered the true end of fileknown_final_byte_positionatomic at the start of each spawned task, and short-circuit if a previous task has already found the file endTest plan
Note
Low Risk
Low risk: small change to prefetch task scheduling that only short-circuits requests once EOF is already known, plus lockfile version bumps.
Overview
Avoids sending redundant reconstruction range requests that would return
416 Range Not Satisfiableby having each spawned prefetch task checkknown_final_byte_positionand exit early when the requested start is already past the discovered EOF.Also bumps
xet-*crate versions from1.4.0to1.5.0in the WASMCargo.lock.Reviewed by Cursor Bugbot for commit 9ff4ed6. Bugbot is set up for automated code reviews on this repo. Configure here.