Repository navigation
perf(proxy): stop probing ranges after fan-out cap - #234
Merged
Merged
Conversation
[Medium impact] The PR appears safe to merge; the previous documentation issue is fully fixed. SummarySparse range reads stop probing after the 33rd confirmed miss and use the existing upstream fallback.
Reviews (3) · Last reviewed commit: "docs: fold the probe cutoff into the pro..." · Reviewed by Greptile |
ovaistariq
approved these changes
Oct 21, 2026
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Sparse range requests now stop cache probing after the 33rd confirmed miss when the per-request fetch cap is 32. Later blocks cannot make assembly eligible again, so the handler uses its existing upstream 206 fallback. The full-object majority scan remains exhaustive.
The proxy tests cover 33-, 50-, and 128-block ranges with early and late cap crossings, including cached blocks after an early cutoff. They check probe keys, exact 206 bytes and Content-Range, metadata retention, no aligned per-block origin requests, cancellation and transient errors, unchanged committed-serve metrics, and no locality samples for skipped probes. The block-caching RFC documents the cutoff. A native Go benchmark and in-process gRPC cache-owner fixture are included; the fixture is shared with the regression tests.
The benchmark exercises
HandleGetObjectwith default 1 MiB blocks, block 0 present and all later blocks absent, and a 1 ms delay per cache-ownerGet. Its upstream test double returns the exact 206 response in-process.ns/opincludes the full response copy;prefallback_ns/opmeasures handler entry to upstream dispatch. These are controlled latency-model results, not observed production cache-peer latency or CPU-isolation results. Each row used 10 paired one-invocation samples with varied arm order. Values are separate base→changed-revision medians; Δ is changed revision−base with the reported at-least-19/20 interval. All values are ns/op.ns/op: 116,189,493→80,704,990; Δ −35,000,860 [−37,886,945, −31,846,927].prefallback_ns/op: 105,362,691→71,189,258; Δ −33,407,490 [−35,990,653, −30,106,750].ns/op: 305,219,011→95,734,572; Δ −212,935,396 [−216,997,752, −206,415,544].prefallback_ns/op: 262,202,676→69,418,219; Δ −195,676,067 [−199,072,188, −187,933,680].To run one native sample, build
go test -c -o /tmp/bench.test ./proxy, then run/tmp/bench.test -test.bench='^BenchmarkBlockCacheRangeFanout$/^blocks50_early_one_hit$' -test.run='^$' -test.count=1or substituteblocks128_early_one_hit.make lint-ci,make build,make test,make test-integration,make test-race,make test-coverage, andgo test ./proxy -run '^TestBlockCache_LargeRangeServeBailsInsteadOfFanningOut$' -count=1passed.Checks: 7 passed.
Generated by Perfloop. Measurements and checks.
Note
Medium Risk
Changes hot-path block-cache range behavior and upstream fallback timing; behavior is heavily tested but affects large sparse range GETs in production.
Overview
Sparse block-mode range reads stop probing once fetch fan-out is ruled out, instead of walking every covering block before falling back to a single upstream range GET.
In
ensureBlocksCached, whenmaxFetchFanoutis positive (range serves use 32), the orderedBlockExistsErrloop now returnserrBlockAssemblyWouldAmplifyas soon as confirmed misses exceed the cap—the 33rd absence—so later blocks are not probed and are not counted for locality. The post-scan absolute fan-out check is removed; the full-object path still passesmaxFetchFanout0 and keeps an exhaustive probe for the majority-missing bail. The block-caching RFC probe-first step is updated to match.Regression coverage adds a shared gRPC cache-owner fixture, tests for early/late cap crossings, at-limit assembly, transient probe errors, cancellation, and a
BenchmarkBlockCacheRangeFanoutbenchmark for prefallback vs full-handler cost on large sparse ranges.Reviewed by Cursor Bugbot for commit b495d90. Bugbot is set up for automated code reviews on this repo. Configure here.