Skip to content

perf(proxy): stream background cache warms directly to cache - #198

Merged
ovaistariq merged 6 commits into
mainfrom
perfloop-pr-open-bkypnx3vqh
Sep 3, 2026
Merged

ovaistariq merged 6 commits into
mainfrom
perfloop-pr-open-bkypnx3vqh

Conversation

@perfloop

@perfloop perfloop Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

The change

Detached full-object cache warms now pass the upstream response body directly to the existing whole-object or block cache writer. Foreground request coalescing still uses the broadcaster listener path.

The existing status, size, cache-control, anonymous ACL, detached-timeout, representation-selection, write-start, and tombstone-aware publication behavior remains in place. The memory budget accounts for the direct transport and storage buffers, and reserves an exact-sized block scratch buffer only when the response selects block mode. Warm-on-write retries create a fresh bounded acquisition context after the origin fetch instead of reusing the pre-fetch wait deadline.

Skipped and failed cache writes drain the upstream body before closing it, preserving connection reuse. The configuration documentation describes the direct-writer reservation.

Tests

  • go test ./proxy/... -count=1
  • go test -race ./proxy -run '^(TestFetchFullObjectToCache_|TestHandlePutObject_WarmOnWrite_|TestSetupCacheListener_|TestStreamFromUpstream_|TestService_BackgroundReservation|TestContextBoundReader|TestWaitForCacheWrite|TestBackgroundPopulateBufferBytes|TestBackgroundReservationIncludesClusteredStreamBuffers|TestBackgroundReservationAddsBlockScratchOnlyAfterSelection|TestGetExactBlockBuf)$' -count=1
  • go vet ./proxy/...
  • make lint-ci

Workload: two concurrent 4 MiB cacheable block-mode background populates under 256 MiB cap

Metric Before After Change
allocs/op 588 379 35.5% lower

Workload: two concurrent 4 MiB cacheable whole-object background populates under 256 MiB cap

Metric Before After Change
allocs/op 422.5 214.5 49.2% lower
Checks: 4 passed.

Generated by Perfloop. Measurements and checks.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR replaces the broadcaster/listener pipeline for detached full-object cache warms with direct streaming into whole-object or block cache writers.

  • Adds path-specific memory accounting for direct cache-client, storage, and block-scratch buffers.
  • Preserves tombstone-aware metadata publication, cacheability checks, anonymous ACL inference, and detached write deadlines.
  • Drains skipped or failed upstream bodies to preserve connection reuse.
  • Adds direct-writer correctness, reservation, cancellation, and allocation benchmark coverage.
  • Updates cache memory-budget configuration documentation.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified.

The direct population path preserves body-before-metadata publication, tombstone checks, anonymous-access handling, bounded admission, and timeout cleanup while removing intermediate broadcaster buffering.

Important Files Changed

Filename Overview
proxy/caching.go Replaces detached broadcaster-based cache population with direct tombstone-aware streaming, bounded cancellation, body draining, and explicit reservation ownership.
proxy/service.go Introduces direct-writer memory weights, split block-scratch admission, and impossible-reservation rejection while retaining foreground relay accounting.
proxy/block_cache.go Uses exact-capacity scratch buffers for direct block population so pooled oversized allocations cannot exceed the charged reservation.
proxy/cache_background_test.go Covers direct whole-object and block writes, draining, timeout detachment, scratch admission, and tombstone-aware publication.
config/config.go Clarifies the memory represented by foreground and direct-background population reservations.
docs/configuration.md Documents path-specific cache-populate memory accounting and block scratch reservation.

Reviews (1): Last reviewed commit: "perf(proxy): bound direct cache memory" | Re-trigger Greptile

@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.

Reviewed by Cursor Bugbot for commit dc7b2ec. Configure here.

Comment thread proxy/caching.go Resolved
@perfloop

perfloop Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 963cd3d90b48. Response to this feedback.

The retry path now creates a new bounded acquisition context after the origin GET rather than reusing the pre-fetch context. This prevents an expired acquisition deadline from declining an otherwise admissible warm.

@ovaistariq
ovaistariq merged commit 80beca1 into main Sep 3, 2026
12 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-bkypnx3vqh branch September 3, 2026 00:33
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 3, 2026
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.21.0 🎉

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.

4 participants