Skip to content

perf(proxy): skip response capture for cache-disabled deletes - #301

Open
perfloop[bot] wants to merge 2 commits into
mainfrom
perfloop-pr-open-w8g1eff7ch
Open

perfloop[bot] wants to merge 2 commits into
mainfrom
perfloop-pr-open-w8g1eff7ch

Conversation

@perfloop

@perfloop perfloop Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Stream cache-disabled DeleteObjects responses through Forward instead of retaining an unused response capture. Cache-enabled result parsing and response fences stay unchanged. Reuse fixed-size copy scratch so small replies do not acquire a fresh copy buffer on every request.

Keep pre-header forwarding errors and the existing post-header return and request-metric behavior. This is not a repair for incomplete response delivery.

Benchmarks

proxy/delete_objects_benchmark_test.go measures complete handler forwarding to a local HTTP origin, with caching disabled, distinct 128-byte keys and non-quiet DeleteResult replies. It includes request buffering and origin work, and checks delivered status, content type and byte count.

Local run with Go 1.27.2: three paired runs per row, alternating arm order, after excluded warmups. Each row ran separately:

go test ./proxy -run '^$' -bench '^BenchmarkHandleDeleteObjectsCacheDisabled$/^1000$' -benchmem -benchtime=1s -count=1
go test ./proxy -run '^$' -bench '^BenchmarkHandleDeleteObjectsCacheDisabled$/^1$' -benchmem -benchtime=1s -count=1

The allocation reduction is the intended improvement. Elapsed time and the one-entry row are controls; these local estimates do not establish a no-regression guarantee. Paired change is the median percentage change within pairs, not a ratio of the separate arm medians.

Entries Metric Before median After median Paired change Pairs
1000 B/op 740039 408977 -44.73% 3
1000 ns/op 989535 897042 -9.35% 3
1 B/op 12997 12273 -5.59% 3
1 ns/op 147949 151628 +1.26% 3
Local paired benchmark rows

Selected native benchmark rows from the local runs above, with warmups excluded. Each before row pairs with the corresponding after row of the same size; execution order alternated between before-first and after-first.

Before (three runs per size, in pair order):

BenchmarkHandleDeleteObjectsCacheDisabled/1000-4         	    1161	    981226 ns/op	  741325 B/op	     195 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1000-4         	    1203	    989535 ns/op	  739857 B/op	     194 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1000-4         	    1135	   1008973 ns/op	  740039 B/op	     194 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1-4 	    7239	    147949 ns/op	   13060 B/op	     146 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1-4 	    7146	    149743 ns/op	   12997 B/op	     146 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1-4 	    7806	    147609 ns/op	   12935 B/op	     146 allocs/op

After (three runs per size, in pair order):

BenchmarkHandleDeleteObjectsCacheDisabled/1000-4         	    1306	    922482 ns/op	  408977 B/op	     169 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1000-4         	    1431	    897042 ns/op	  408884 B/op	     169 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1000-4         	    1364	    862378 ns/op	  409212 B/op	     169 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1-4 	    7236	    147442 ns/op	   12299 B/op	     141 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1-4 	    8320	    151628 ns/op	   12271 B/op	     141 allocs/op
BenchmarkHandleDeleteObjectsCacheDisabled/1-4 	    8451	    162170 ns/op	   12273 B/op	     141 allocs/op

An allocation profile of the large-reply run no longer attributes samples to executeAndCapture after the change. Small-reply timing estimates varied in both directions, including in a longer control run.

Request bodies remain buffered, and the pool may retain fixed-size scratch between requests. Peak heap, CPU time, p99 latency and production input prevalence remain unmeasured; ns/op above is elapsed handler time.

Testing

Focused Go tests for bulk-delete forwarding, response-byte accounting and routed response fences passed. They cover status/header/body preservation, transport and body-copy failures, upstream closure, streaming progress and enabled-cache fencing. Formatting and module-consistency checks passed.


Made by Perfloop. To ask for a change, comment or review in plain words. How Perfloop handles pull requests.


Note

Medium Risk
Changes the bulk-delete proxy forwarding path and error-return semantics for cache-disabled traffic, though behavior is explicitly preserved and tested; cache-enabled invalidation logic is untouched.

Overview
When caching is off, bulk DeleteObjects now streams upstream responses via Forward instead of buffering them with ForwardWithCapture, since per-key <Error> parsing is only needed for cache fencing. The cache-enabled path is unchanged: capture, staged headers, and post-success re-invalidation still run as before.

Streaming uses a sync.Pool of 32 KiB scratch buffers and io.CopyBuffer so body copies do not allocate a fresh buffer every request. A small deleteObjectsStreamWriter wraps the existing statusRecorder so post-header copy failures still do not surface as the handler error (matching prior capture forwarding), while status, headers, body passthrough, outbound byte metrics, and upstream body closure stay covered by new tests and a cache-disabled benchmark.

Reviewed by Cursor Bugbot for commit bb8420d. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Cache-disabled DeleteObjects calls now stream through Forward without keeping a response copy.

  • Cache-disabled bulk deletes stream replies with pooled copy buffers.

perfloop[bot] explicitly states that repairing incomplete response delivery is outside this PR’s scope. The existing post-header return and request-metric behavior is preserved.

Review was based on source inspection; tests and benchmarks were not run.

Reviews (1) · Last reviewed commit: "perf(proxy): skip response capture for c..." · Reviewed by Greptile

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant