Repository navigation
fix(gateway): key the manifest fill lock per hash - #2866
Conversation
manifest() held one gateway-wide mutex across the whole pull_manifest, so a stalled pull for one hash made every request for every other uncached bundle queue behind it. The fill lock is now one async lock per hash, held as a Weak in a map whose entries vanish when the last waiter drops, and a small semaphore bounds how many fills buffer at once. Closes #2848 Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 3 most impacted files.
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
…fill failures A fill now takes its manifest fill slot once its first bytes arrive, not before the pull starts, so pulls still looking for a holder buffer nothing and hold no slot: four stalled discoveries no longer block every other uncached manifest. The fill buffer grows by hand within MAX_MANIFEST_BYTES. Pool-paid requests that waited on a pool-paid fill which failed upstream answer with its failure instead of each pulling again in turn. The flight map prunes finished fills in amortized O(1) per new entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ReviewThe per-hash lock does what it should: a stalled manifest pull no longer blocks other hashes. The issues below are in the two parts added around it: sharing a failed fill's error, and the four fill slots. I read the code but did not build or run the tests. Bugs1. A shared failure can stick with no new pull ( 2. The shared failure ignores the routing namespace ( 3. A fill waiting for a slot still holds a pull-worker slot ( Cleanups4. 5. A second copy of the 6. No test for failure expiry or a namespace split ( Design decision7. Four slow upstreams can still block every other new manifest (
Open question: which option, and whether it belongs in this PR or a follow-up. 🤖 Generated with Claude Code |
…red bytes Key each fill lock by hash and routing namespace, so a pull routed through one namespace neither waits on nor shares another's fill. Share a failed fill's upstream error only with requests that waited on that fill: a fill counter read before the wait tells them apart, so a request that comes after the failure pulls again. Bound manifest fills by the bytes their buffers hold rather than by a count of fills. A fill takes budget as its buffer grows and fails at once past it, so no pull parks on a worker slot and trickling upstreams hold only the bytes they delivered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed in 3079c91. 1. Sticky failure — fixed. Each fill lock carries a counter of ended fills. A request reads it before it waits and reuses the stored failure only if a fill ended after it arrived; otherwise it pulls itself. A request that comes after the failure always pulls again. Test: 2. Namespace — fixed. The flight is keyed by 3 + 7. Fill slots — replaced with a byte budget. Taking the slot before
Tests: 4. 5. Shared helper — kept in #2868. Moving it here would still leave the cache engine's copy, because that crate is out of this PR's scope, so this PR would add a module without removing a copy. The crate choice is also a design call: 6. Tests — added, as listed above. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gas snapshotNo gas changes vs base. |
manifest()held one gateway-wide mutex across the wholepull_manifest, so a pull for a hash nobody holds — up to 120 s per silent gap, unbounded while bytes trickle — made every request for every other uncached bundle queue behind it. The field's own doc already described the intended scope as per hash.The fill lock is now per hash and routing namespace, using the same Weak-map flight pattern as the cache engine's outboard fills: waiters hold the Arc, entries vanish on the last drop (cancellation-safe, no leak), and the double-checked cache read keeps one paid pull per hash and namespace. A pull routed through one namespace neither waits on nor shares another's fill. The map prunes finished fills in amortized O(1) per new entry.
A byte budget bounds the manifest bytes buffered at once to four buffers at the manifest cap (256 MiB), so the per-hash change does not trade the serialization for sixteen 64 MiB manifest buffers. A fill takes budget for its buffer's capacity as the buffer grows, so a pull still looking for a holder, or one whose bytes trickle in, holds only what it has buffered. A fill that would pass the budget fails at once instead of waiting: no pull parks on a worker slot, and two fills each holding part of the budget cannot wait on each other.
On a public gateway, requests that waited on a fill which failed upstream answer with its failure instead of each pulling again in turn. A fill counter read before the wait limits this to requests that were waiting when the fill ended, so a request that comes after the failure pulls again. Funding and allowance stops are not shared.
Follow-up for the cache engine's copy of the flight map: #2868.
Closes #2848
🤖 Generated with Claude Code