Skip to content

perf(proxy): stop probing ranges after fan-out cap - #234

Merged
ovaistariq merged 4 commits into
mainfrom
perfloop-pr-open-0s2warxdkr
Oct 21, 2026
Merged

ovaistariq merged 4 commits into
mainfrom
perfloop-pr-open-0s2warxdkr

Conversation

@perfloop

@perfloop perfloop Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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 HandleGetObject with default 1 MiB blocks, block 0 present and all later blocks absent, and a 1 ms delay per cache-owner Get. Its upstream test double returns the exact 206 response in-process. ns/op includes the full response copy; prefallback_ns/op measures 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.

  • 50 blocks — 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].
  • 128 blocks — 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=1 or substitute blocks128_early_one_hit.

make lint-ci, make build, make test, make test-integration, make test-race, make test-coverage, and go test ./proxy -run '^TestBlockCache_LargeRangeServeBailsInsteadOfFanningOut$' -count=1 passed.

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, when maxFetchFanout is positive (range serves use 32), the ordered BlockExistsErr loop now returns errBlockAssemblyWouldAmplify as 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 passes maxFetchFanout 0 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 BenchmarkBlockCacheRangeFanout benchmark 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.

@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous documentation issue is fully fixed.

Summary

Sparse range reads stop probing after the 33rd confirmed miss and use the existing upstream fallback.

  • Sparse range reads stop probing after the 33rd confirmed miss.

Reviews (3) · Last reviewed commit: "docs: fold the probe cutoff into the pro..." · Reviewed by Greptile

Comment thread docs/rfcs/0001-block-aligned-caching.md Resolved
@ovaistariq
ovaistariq merged commit 0120be7 into main Oct 21, 2026
9 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-0s2warxdkr branch October 21, 2026 18:56
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.22.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants