Skip to content

fix(cache): add an idle deadline for body streams - #222

Closed
perfloop[bot] wants to merge 5 commits into
mainfrom
perfloop-pr-open-mgd1q9m4kr
Closed

perfloop[bot] wants to merge 5 commits into
mainfrom
perfloop-pr-open-mgd1q9m4kr

Conversation

@perfloop

@perfloop perfloop Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Cached object reads now use a configurable idle timeout for whole-object, range, and block-range streams. Each read derives a child context from the request, resets the timeout after each non-empty cache chunk, and pauses the timeout while the destination write is in progress. The default is 60 seconds and is documented in the YAML and environment configuration.

The cache-hit path keeps response headers uncommitted until the first body chunk so an idle read can fall back upstream without sending cache bytes. Once headers are committed, idle failures remain partial cache responses and never start an upstream remainder request. A late cache chunk cannot commit a response after the watchdog has canceled the read. Healthy streams use an idle-gap policy rather than a total transfer deadline.

Tests cover context propagation, first and inter-chunk stalls, empty chunks, healthy gaps, slow destination writes, whole-object ranges, block ranges, pre-header fallback, and post-commit behavior. Validation runs make lint-ci, make build, make test, make test-integration, make test-race, make test-coverage, and make vet.

Workload: stalled concurrent cache-hit admission

Metric Before After Change
ns/op 81814699 11079713 86.5% lower
request_p95_ns 42555852 6165843 85.5% lower
capacity_recovery_ns/op 40615667 5173820 87.3% lower
Checks: 7 passed.

Generated by Perfloop. Measurements and checks.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; both previous findings are resolved and no new actionable failures remain.

Summary

  • Applies a child cancellation context consistently across cache streaming paths.
  • Defers response commitment so pre-header idle failures can fall back upstream.
  • Prevents late cache chunks and post-commit upstream remainder requests after idle cancellation.
  • Adds configuration documentation and coverage for stalls, healthy gaps, slow writers, ranges, and block streams.

Reviews (2) · Last reviewed commit: "perf: publish progress before idle state..."

Comment thread cache/body_read.go Resolved
Comment thread cache/cache.go Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4d72a57. Configure here.

Comment thread cache/body_read.go Resolved
@perfloop
perfloop Bot force-pushed the perfloop-pr-open-mgd1q9m4kr branch from 4d72a57 to 0a871fe Compare September 10, 2026 02:05
@perfloop

perfloop Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 0a871fed655b. Response to this feedback.

The cache-read watchdog now covers the complete body and range paths, rejects late chunks after cancellation, and keeps committed failures terminal. Added boundary tests cover these response and cancellation cases.

@ovaistariq

Copy link
Copy Markdown
Contributor

Superseded by #270: a size-scaled context.WithTimeout per cache read (30s floor + 1s/MiB for buffered reads and probes, a flat 5-minute cap equal to the server WriteTimeout for client-paced streams) instead of the idle watchdog, per-write CAS and new config key.

@ovaistariq ovaistariq closed this Oct 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants