Skip to content

perf(proxy): avoid lowercasing ordinary response headers - #206

Merged
ovaistariq merged 4 commits into
mainfrom
perfloop-pr-open-bh3hk9dnpr
Oct 21, 2026
Merged

ovaistariq merged 4 commits into
mainfrom
perfloop-pr-open-bh3hk9dnpr

Conversation

@perfloop

@perfloop perfloop Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

copyHeaders now checks the fixed x-amz-meta- prefix case-insensitively before lowercasing. Metadata keys still use lowercase S3 form; other response keys and their value slices retain their existing spelling and assignment.

TestCopyHeaders_MixedCaseMetadataPrefix covers mixed-case and uppercase metadata, the bare prefix, a near miss, short names, and value-slice identity. The existing full-GET miss benchmark is proxy/cache_populate_benchmark_test.go (BenchmarkCacheableGetHandlerCompletion); it runs with go test ./proxy -run '^$' -bench '^BenchmarkCacheableGetHandlerCompletion$' -benchmem. The controlled signing-mode header-mix harness and the warning-level log setting used for these measurements are support outside this PR.

Verification

  • make lint-ci
  • make build
  • make test-proxy
  • make test-integration TEST=TestCache_HeaderPreservation

The table includes direct copyHeaders mixes with canonical ordinary header names, the signing-mode forwarding path, and a guard on the existing cacheable GET benchmark. The signing-mode harness uses a controlled upstream response with HTTP 200 and http.NoBody; neither it nor the existing GET benchmark replays production traffic. Go ns/op is elapsed time, not CPU time. Production response-header mix, request frequency, and aggregate impact remain unmeasured.

Workload Measure Metric Before median After median Paired change Outcome / requirement Paired runs
copyHeaders with 10 ordinary response headers and no metadata headers time ns/op 1.009 µs 0.276 µs -72.7% improvement passed 9
copyHeaders with 10 ordinary response headers and no metadata headers allocated bytes B/op 240 B 0 B -100% improvement passed 9
copyHeaders with 10 ordinary response headers and no metadata headers allocations allocs/op 10 0 -100% improvement passed 9
copyHeaders with 9 ordinary and 1 metadata response header time ns/op 1.023 µs 0.3692 µs -63.9% improvement passed 11
copyHeaders with 9 ordinary and 1 metadata response header allocated bytes B/op 240 B 24 B -90% improvement passed 11
copyHeaders with 9 ordinary and 1 metadata response header allocations allocs/op 10 1 -90% improvement passed 11
copyHeaders with 4 ordinary and 8 metadata response headers time ns/op 1.331 µs 1.043 µs -21.3% improvement passed 12
copyHeaders with 4 ordinary and 8 metadata response headers allocated bytes B/op 288 B 192 B -33.3% improvement passed 12
copyHeaders with 4 ordinary and 8 metadata response headers allocations allocs/op 12 8 -33.3% improvement passed 12
signing-mode Service.HandlePassthrough for GetObjectTagging with 10 ordinary and no metadata response headers; controlled upstream returns HTTP 200 with http.NoBody time ns/op 41.08 µs 39.94 µs −1.3% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| ns 13
signing-mode Service.HandlePassthrough for GetObjectTagging with 10 ordinary and no metadata response headers; controlled upstream returns HTTP 200 with http.NoBody allocated bytes B/op 18.56 kB 18.32 kB −1.3% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| B 13
signing-mode Service.HandlePassthrough for GetObjectTagging with 10 ordinary and no metadata response headers; controlled upstream returns HTTP 200 with http.NoBody allocations allocs/op 181 171 -5.5% improvement passed 13
signing-mode Service.HandlePassthrough for GetObjectTagging with 9 ordinary and 1 metadata response header; controlled upstream returns HTTP 200 with http.NoBody time ns/op 40.57 µs 39.45 µs −2.8% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| ns 13
signing-mode Service.HandlePassthrough for GetObjectTagging with 9 ordinary and 1 metadata response header; controlled upstream returns HTTP 200 with http.NoBody allocated bytes B/op 18.56 kB 18.33 kB −1.2% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| B 13
signing-mode Service.HandlePassthrough for GetObjectTagging with 9 ordinary and 1 metadata response header; controlled upstream returns HTTP 200 with http.NoBody allocations allocs/op 181 172 −5% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| 13
signing-mode Service.HandlePassthrough for GetObjectTagging with 4 ordinary and 8 metadata response headers; controlled upstream returns HTTP 200 with http.NoBody time ns/op 41.16 µs 40.24 µs −2.4% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| ns 14
signing-mode Service.HandlePassthrough for GetObjectTagging with 4 ordinary and 8 metadata response headers; controlled upstream returns HTTP 200 with http.NoBody allocated bytes B/op 18.61 kB 18.52 kB −0.5% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| B 14
signing-mode Service.HandlePassthrough for GetObjectTagging with 4 ordinary and 8 metadata response headers; controlled upstream returns HTTP 200 with http.NoBody allocations allocs/op 183 179 −2.2% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| 14
cacheable full GET miss through Service.HandleGetObject with a local HTTP server, in-memory cache, small body, and controlled mock upstream response time ns/op 234.9 µs 232.1 µs −1% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| ns 14
cacheable full GET miss through Service.HandleGetObject with a local HTTP server, in-memory cache, small body, and controlled mock upstream response allocated bytes B/op 179.4 kB 179.3 kB -0.0655 kB non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| B 14
cacheable full GET miss through Service.HandleGetObject with a local HTTP server, in-memory cache, small body, and controlled mock upstream response allocations allocs/op 189 185 −2.1% non-regression passed; lower is better; required population loss ≤ 0.05 × |baseline median| 14

Generated by Perfloop.


Note

Low Risk
Localized header-copy optimization with explicit tests; behavior for metadata normalization and ordinary headers is preserved or clarified.

Overview
copyHeaders now detects S3 metadata keys with a length check and case-insensitive prefix match on x-amz-meta-, and only then lowercases the full key. Non-metadata response headers are copied with their original key spelling and the same value slices—no upfront strings.ToLower on every header.

Adds TestCopyHeaders_MixedCaseMetadataPrefix for mixed-case/uppercase metadata, the bare prefix, near-miss names, short keys, and unchanged slice assignment.

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

@greptile-apps

greptile-apps Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

copyHeaders now checks the metadata prefix before lowercasing a header name.

  • Proxy responses check ordinary header names without lowercasing them first.

Reviews (3) · Last reviewed commit: "test(proxy): drop redundant response-hea..." · Reviewed by Greptile

ovaistariq
ovaistariq previously approved these changes Oct 21, 2026
@ovaistariq
ovaistariq merged commit 79f80c3 into main Oct 21, 2026
12 of 13 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-bh3hk9dnpr branch October 21, 2026 18:34
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.22.3 🎉

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.

3 participants