Skip to content

transport/http: make inbound header preallocation configurable - #2536

Open
bananacocodrilo wants to merge 2 commits into
mainfrom
wt/header-preallocation-strategy
Open

transport/http: make inbound header preallocation configurable#2536
bananacocodrilo wants to merge 2 commits into
mainfrom
wt/header-preallocation-strategy

Conversation

@bananacocodrilo

@bananacocodrilo bananacocodrilo commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Description

Intent:

  • Preserve PR transport/http: preallocate inbound headers #2521's fast post-system-header sizing as the default while giving services an escape hatch for requests dominated by unrelated HTTP headers.
  • Let downstream services choose the CPU and memory tradeoff that matches their inbound header mix.

Changes:

  • Added unfiltered, scan, and disabled inbound header preallocation strategies through the Go API and HTTP transport configuration.
  • Made unfiltered the zero-value default; it uses the unfiltered number of request headers remaining after YARPC system headers are removed.
  • Made the opt-in scan count unique application, tracing, proxy, and grabbed headers, including raw/prefixed collisions and empty grabbed values.
  • Removed the small-header threshold: scanning has already paid the counting cost, and benchmarks showed capacity zero and capacity four both used 744 B/op and 8 allocs/op.
  • Precomputed grabbed-header lookup keys per inbound so scanning adds no per-request allocations.

Test Plan

  • go test ./transport/http
  • aifx verify
  • go test ./transport/http -run '^$' -bench '^BenchmarkFromHTTPHeadersCapacity/small/' -benchmem -benchtime=200ms -count=3

Revert Plan

Revert this PR to restore PR #2521's unconditional post-system-header request-header-count preallocation.

Issues

T3-RPC-11408

RELEASE NOTES:
Added configurable inbound HTTP header preallocation strategies.

Summary:
Intent:
- Preserve the default post-system-header sizing from PR #2521 while giving header-heavy services an escape hatch for requests dominated by unrelated HTTP headers.
- Let downstream services choose the CPU and memory tradeoff that matches their inbound header mix.

Changes:
- Added remaining, scan, and disabled inbound header preallocation strategies through the Go API and HTTP transport configuration.
- Made the opt-in scan count unique application, tracing, proxy, and grabbed headers, including collision and minimum-threshold handling.
- Precomputed grabbed-header lookup keys per inbound so scanning adds no per-request allocations, with focused tests and benchmarks for each strategy.

Jira Issues: T3-RPC-11408

---

<sub>Generated by the 🪄 [pr-create](https://sg.uberinternal.com/code.uber.internal/uber-code/devexp-agent-marketplace/-/blob/claude-code/plugins/dev/uber-dev/skills/pr-create/SKILL.md) skill in devexp-agent-marketplace</sub>
@bananacocodrilo
bananacocodrilo marked this pull request as ready for review August 19, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant