Group small-entry transfers with div_ceil so exact-multiple sizes stop overshooting by a chunk - #853
Open
CleanCut wants to merge 2 commits into
Open
Group small-entry transfers with div_ceil so exact-multiple sizes stop overshooting by a chunk#853CleanCut wants to merge 2 commits into
CleanCut wants to merge 2 commits into
Conversation
…p overshooting by a chunk Both `pull_small_entries` and `download_small_entries` sized their chunk groups with the `(total / segment) + 1` idiom the repo guidelines warn against. When `total_size` is an exact multiple of the segment size it asked for one more group than needed, yielding marginally smaller groups. Not a correctness bug at these two sites — the `num_chunks > entries.len()` guard kept it from ever requesting a zero-byte range — but it left two different idioms in the tree for the same computation. Swapping in `div_ceil` on its own would have introduced a panic: it returns 0 when every entry is zero bytes, and the next line divides `entries.len()` by that count. The `.max(1)` floor keeps the divisor non-zero, which the `+ 1` form had been providing by accident. ENG-1229
Contributor
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe small-file pull and download paths now use ceiling division and enforce a minimum chunk count of one. ChangesSmall-file chunking
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/liboxen/src/core/v_latest/fetch.rs`:
- Around line 731-732: Update pull_small_entries in
crates/liboxen/src/core/v_latest/fetch.rs at lines 731-732 so its
entries-per-group calculation uses ceiling division via
entries.len().div_ceil(num_chunks). Apply the same change in
download_small_entries at lines 974-975; both sites must use ceiling division to
avoid extra requests for non-divisible entry counts.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d9ad1dc7-34d5-4d8c-834b-7345d98d5184
📒 Files selected for processing (1)
crates/liboxen/src/core/v_latest/fetch.rs
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.
Both
pull_small_entriesanddownload_small_entriessized their chunk groups with the(total / segment) + 1idiom the repo guidelines warn against. Whentotal_sizeis an exact multiple of the segment size it asked for one more group than needed, yielding marginally smaller groups.Swapping in
div_ceilon its own would have introduced a panic: it returns 0 when every entry is zero bytes, and the next line dividesentries.len()by that count. The.max(1)floor keeps the divisor non-zero, which the+ 1form had been providing by accident.Fixed a similar problem with
chunk_size, where it should only be0when the number of entries is0.ENG-1229