Repository navigation
perf(proxy): avoid cache populate completion wait - #148
Conversation
|
All contributors have signed the CLA. ✅ |
Greptile SummaryThis PR removes the cache-population completion delay from cacheable full GET responses while preserving asynchronous publication and late-error reporting.
Confidence Score: 5/5The PR appears safe to merge; no concrete correctness, resource-lifecycle, or security failure remains. Cache population remains detached under a bounded context, its result channel and populate slot are cleaned up on all examined paths, and both immediate and late write failures remain observable. Important Files Changed
Reviews (1): Last reviewed commit: "perf(proxy): avoid cache populate comple..." | Re-trigger Greptile |
|
I have read the CLA Document and I hereby sign the CLA |
|
Thanks for the contribution. This looks good. |
|
🎉 This PR is included in version 1.17.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Behavior
Cache publication remains asynchronous and subject to the existing admission and write-timeout limits. A follow-up request can still be a miss until the detached populate finishes.
Testing
make lint-cimake test-proxygo test -race -timeout 120s ./proxy/...go vet ./proxy/...Workload:
cacheable-full-get-miss-handler-completionns/opAuthored and verified by Perfloop: every claim above was co-measured on both trees and independently re-verified before submission — the full record is public: case_mtzbwvz133. Replies from this account are human-approved, and a human operator is accountable for this contribution.
Note
Medium Risk
Changes timing and cancellation behavior on the hot GET/cache-populate path; correctness relies on detached listeners and late-error handling, with substantial new tests but real production concurrency edge cases.
Overview
Cacheable full-GET misses now finish the upstream streaming path as soon as the body is read, instead of waiting up to 100ms (or longer) for detached cache population.
In
streamFromUpstream, the handler no longer blocks oncacheErrCh; it logs an immediate cache-write error if one is already available, otherwise spawns a goroutine to log late failures.fetchAndBroadcastcan callbroadcaster.Completeafter upstream EOF so listeners close promptly while populate continues in the background.Listener.WaitForHeadersre-checksheaderChwhenctxis already canceled, so a cache listener scheduled after the HTTP handler returns still sees ready headers and can publish the entry instead of losing the race to cancellation.Regression coverage adds benchmarks and tests for handler completion timing, a follow-up cache hit on a separate connection, the header-vs-cancel boundary, late cache-write logging, and populate slot release.
Reviewed by Cursor Bugbot for commit 8011290. Bugbot is set up for automated code reviews on this repo. Configure here.