feat(cache-proxy): per-request phase timing, in-flight gauge, pprof - #1045
Merged
EDsCODE merged 1 commit intoAug 9, 2026
Merged
Conversation
EDsCODE
marked this pull request as ready for review
August 9, 2026 19:03
Production requests spend 100-400ms each inside the proxy with no per-request visibility. Adds dur_ms/peer_ms/s3_ms/write_ms to the Served. log line, dur_ms to Forward-proxy served., a request-duration histogram by path and source, an in-flight gauge, a forward-path method counter (quantifies the co-tenant HEAD stream), and pprof on the health mux. Instrumentation only; no request-path behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
EDsCODE
force-pushed
the
eric/cache-proxy-phase-timing
branch
from
August 9, 2026 19:21
e128e2d to
40d1c43
Compare
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.
Problem
Production investigation of slow cold scans found requests spending 100-400ms each inside the cache proxy, served strictly one at a time, with every externally observable component healthy — no errors, no retries, idle CPU, fast peers. The proxy exposes no per-request timing, no queue-depth signal, and no pprof, so the remaining decomposition (origin fetch vs disk vs response write vs queueing) is unmeasurable. Separately, a continuous stream of co-tenant HEAD requests was found traversing the uncached forward path to origin with no metric counting it.
Change
Instrumentation only — no request-path behavior changes:
Served.log line gainsdur_ms,peer_ms,s3_ms,write_ms(existing fields unchanged, in order).Forward-proxy served.gainsdur_ms.cache_proxy_request_duration_secondshistogram, labels{path=block|forward, source}, 1ms–8s exponential buckets.cache_proxy_inflight_requestsgauge aroundHandleProxy— the queue-depth signal. Note: CONNECT tunnels count for their lifetime.cache_proxy_forward_requests_total{method}counter — quantifies the forward-path HEAD stream.DefaultServeMux).docs/metrics.mddocuments the new family, distinguishing it from the worker-sideduckgres_worker_cache_proxy_*view.Accounting nuance: origin-fetch time under singleflight is attributed to the winning request; followers' waits appear in
dur_msbut nots3_ms.Testing
go test ./cmd/cache-proxy -count=1green;-racegreen except the pre-existingTestHandleConnectLogsOpenAndCloserace (fails identically on the base branch).dto.Metrichelper convention.Notes
Stacked on #1042 (seek fix) — both touch the serve loop. Merge that first; this PR's base is set accordingly.
🤖 Generated with Claude Code