Repository navigation
test(cache): pin single-pull coalescing of concurrent misses (#530) - #553
Merged
Merged
Conversation
Adds `coalesced_concurrent_misses_fire_origin_exactly_once` in `crates/cache/tests/pull_through.rs`. Spawns 10 concurrent `engine.get(hash)` tasks for an uncached blob against a `SlowOnceOrigin` helper (sleeps 25ms before serving) and asserts the origin saw exactly one fetch. The existing `coalesced_owner_retry_unblocks_waiters_on_success` already pins coalescing under retry (`origin.fetches() == 3`); this is the missing happy-path companion that pins `== 1` on the no-failure path so a regression breaking coalescing — duplicate origin charges, duplicate iroh-blobs inserts — shows up without retry noise muddying the count. `SlowOnceOrigin` mirrors the shape of `FailingThenSucceedingOrigin` (atomic fetch counter, `OriginFetch::found_one_shot`) but takes a `Duration` delay instead of a failure count. The delay is load-bearing: an instantaneous fetch can complete before any waiter is scheduled, making a coalescing assertion trivially pass for the wrong reason. Also: backfill `buffered_max_bytes` in the three pre-#519 `RetryPolicy` struct literals introduced by #538, which now don't compile because #519 added the field after #538 landed. Closes #530. https://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo
There was a problem hiding this comment.
Code Review
This pull request introduces a new test case to verify that concurrent misses for the same hash are correctly coalesced into a single origin fetch. To support this, a SlowOnceOrigin helper was added to simulate delayed fetches, and existing retry policy tests were updated to include the buffered_max_bytes field. I have no further feedback to provide.
Coverage reportTotal: 89.01% (was 89.16%, ▼ 0.15%) — 13770/15470 lines
History
|
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
Adds
coalesced_concurrent_misses_fire_origin_exactly_onceincrates/cache/tests/pull_through.rs. Spawns 10 concurrentengine.get(hash)tasks for an uncached blob against a newSlowOnceOrigintest helper (sleeps 25ms before serving) and asserts the origin saw exactly one fetch. The existingcoalesced_owner_retry_unblocks_waiters_on_successalready pins coalescing under retry (origin.fetches() == 3); this is the missing happy-path companion that pins== 1on the no-failure path, so a regression breaking coalescing — duplicate origin charges, duplicate iroh-blobs inserts — shows up without retry noise muddying the count.SlowOnceOriginmirrors the shape of the existingFailingThenSucceedingOrigin(atomic fetch counter,OriginFetch::found_one_shot) but takes aDurationdelay instead of a failure count. The delay is load-bearing: an instantaneous fetch can complete before any waiter is scheduled, making a coalescing assertion trivially pass for the wrong reason.Also backfills the
buffered_max_bytesfield in the three pre-#519RetryPolicystruct literals introduced by #538 — they no longer compile because #519 added the field after #538 landed.Closes #530.
Test plan
cargo test -p decdn-cache --test pull_through coalesced— 3/3 pass (2 existing + 1 new)cargo test -p decdn-cache --lib retry::— 9/9 pass (buffered_max_bytesbackfill verified)cargo clippy -p decdn-cache --tests -- -D warnings— cleancargo fmt -- --check— cleanhttps://claude.ai/code/session_01WimP9WEV6zXWiVNJRBnCNo
Generated by Claude Code