Skip to content

POC: General lazy HTTP/1.1 request-header values - #69963

Closed
davidfowl wants to merge 22 commits into
mainfrom
perfboss/lazy-user-agent-poc
Closed

davidfowl wants to merge 22 commits into
mainfrom
perfboss/lazy-user-agent-poc

Conversation

@davidfowl

@davidfowl davidfowl commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

POC: General lazy HTTP/1.1 request-header values

Description

Discussion draft, not a shipping recommendation. HTTP/1.1 is the protocol restriction, not a User-Agent-only restriction. The implementation generalizes ordinary known and unknown values; names remain eager. The generalized 60-run primary and 24-run supplemental Crank comparisons are complete and preserved. Unread allocation rate falls, but reported timeouts, shared-host uncertainty and read/default-off concerns prevent an overall throughput recommendation. Earlier User-Agent results remain historical, not generalized evidence.

Hypothesis and implementation

Can deferring changing unread values improve HTTP/1.1 workloads beyond existing known-name and stable-value reuse, without unacceptable read/default-off or retained-memory costs?

The new default-off Microsoft.AspNetCore.Server.Kestrel.Experimental.LazyRequestHeaders switch enables the explicit HTTP/1.1 ingress only; it does not silently broaden/alias the historical LazyUserAgent switch. HTTP/1.0, HPACK/QPACK, HTTP/2/HTTP/3 literal ingestion and trailers stay eager. Shared layout/accessor costs are still real.

One collection-owned byte arena grows geometrically up to 4096 bytes, with an aggregate copied-byte budget including discarded holes. Generated known slots and a single authoritative case-insensitive unknown dictionary carry decoded-or-range values. No borrowed input slices, raw placeholders or competing unknown sidecars. Names retain eager validation and existing interning. Host, Content-Length, Connection and Transfer-Encoding remain eager for host/framing/keep-alive processing.

Value reads materialize once; presence queries do not. Set/remove/reset discard unread values without decoding, clearing sensitive bytes. Growth clears the old buffer. Duplicate occurrences materialize the first value and append in order. Empty remains present. Non-ASCII, custom selectors, oversize and budget exhaustion fall back to eager decoding; validation/errors remain at ingestion. Decoded stable known strings retain reuse.

Alternatives and tradeoffs

Existing stable-known reuse is the baseline, not an always-allocating strawman. Response raw serialization is not request-buffer ownership. Borrowed pipe/parser buffers are unsafe without a lifetime redesign; lazy names and consumer hints are deferred. No ignored-header/public API contract is introduced.

Copying, scanning, clearing, per-known-slot metadata, larger unknown entries, retained capacity and first-read/default-off costs require measurement. The arena budget is an untuned hypothesis. Public prior art #38585/#42681 concerns reuse correctness; #31492 concerns known-header memory/coverage; #27467 typed APIs. None proves a lazy-allocation win.

Current generalized correctness

  • 9317 Core header/parser/HTTP/1 cases pass, including fresh independent value-reader paths across eligible known names, unknown X-Example and typed-unknown Alt-Svc, on/off; ownership, duplicates, mutation without decoding, presence, empty/missing, arena growth/exact budget/fallback/secret clearing, encoding/validation, reset/reuse, CopyTo argument errors and eager controls.
  • 777 HTTP/2/HTTP/3/hosted cases pass, five platform/TLS skips, including fragmented 255/256/257-byte known/unknown values, body reads before access, keep-alive reuse, eager HTTP/1.0 and HTTP/2/QPACK compatibility, and switch-enabled Host/Content-Length rejection.
  • Two earlier broad functional runs each failed a different existing asynchronous test. Both cases plus new hosted cases then passed together, followed by the passing full selection. Failed logs remain; no cause is inferred or failure hidden by the repeat. Private-layout reflection probes preserve their original pooled-reference clearing assertions.
  • Frozen generalized source 96def7878b6e2ff7fb5f1afd73e54b4be35c103d passes the broader 777-case functional selection again and 96 real-socket requests (12 processes, eight requests per persistent connection), exact body/length/checksum, with actual local Core identity verified. Current methodology and source. Full per-file manifests and matched binaries are preserved with the evidence.

Generalized end-to-end methodology

The expanded fixed-length fixture sends stable/changing Accept, Accept-Language, User-Agent, X-Example and X-Request-Nonce. Modes: ignore/read-one/read-all/enumerate, known/unknown duplicates and budget fallback. Socket checks assert actual body, observed length and checksum, not only value counts.

Completed primary comparison: five rotating/interleaved repeats of stable/changing x ignore/read-all x baseline/head-off/head-on. Original net12 runtime, identical application/dependencies and server-GC configuration, replacing only baseline Core DLL; full payload manifests, loaded binary/runtime identities, raw counters, latencies, errors and failed attempts retained. Local shared two-core loopback is diagnostic evidence, not an isolated server ceiling. Allocation rates are not bytes/request; no MAX-rate/total-request arithmetic.

Three initial generalized pilots had positive metrics and zero errors. The first full-duration baseline run reported seven socket timeouts, zero bad responses, 1,192,592 requests; its guard stopped the plan. All evidence and traceback are retained. After a separately tested CopyTo argument-compatibility correction, the frozen-head plan records socket errors in all predetermined cases without filtering/replacement; bad responses or missing measurements still fail. This is an explicit stopping-policy change, not a clean-run claim or a client-settings change.

Generalized primary results

60/60 runs, 67,899,721 measured requests, zero bad responses, 324 wrk-reported timeouts across 30 runs (baseline/off/on: 124/106/94). All runs have positive metrics and verified loaded Core/runtime identities. The archive retains 188,023 timestamped measurements; every run contributes 24 interior-window server allocation samples.

Case Median RPS base / off / on Allocation MB/s base / off / on Timeouts base / off / on
Ignore stable 37794 / 38625 / 39049 16.078 / 16.690 / 10.680 35 / 21 / 40
Ignore changing 37096 / 37943 / 38526 24.753 / 26.085 / 10.568 36 / 42 / 8
Read-all stable 38825 / 37580 / 36960 17.724 / 17.555 / 16.685 25 / 12 / 35
Read-all changing 37461 / 36632 / 37278 26.569 / 26.061 / 26.047 28 / 31 / 11

Unread values reduce allocation rate, including stable unknown values that baseline does not reuse. Reading all changing values removes that advantage. Paired changing/ignore on/base RPS has median +1.86%, range -1.81% to +7.03%; read-all/stable has median -2.26%, range -9.61% to +0.38%, and its off/base control median -2.54%, range -7.24% to +2.06%. No trustworthy overall throughput win or acceptable read/default-off regression budget is established.

The pinned wrk completion path counts observations outside its bounded latency histogram as timeouts; reported percentiles exclude those observations. Small P99/max therefore do not establish harmless errors. Their cause is unestablished; they occur on all variants. Raw results retain all errors without replacement. Socket smoke separately checks actual bodies; wrk's bad-response counter is not a body validator.

All per-run metrics, group/paired distributions, raw results, logs, identities and reproduction assets. The README records full observed ranges, latency, counter-window methodology, environment, hashes and limitations.

Generalized supplemental diagnostics

24/24 predetermined runs, 26,054,458 requests, zero bad responses, nine wrk-reported timeouts across three runs (base/off/on: 0/2/7). Read-one/changing, enumerate/changing, and ignore/read-all with known duplicates, unknown duplicates or a 4000-byte X-Budget are each measured once per variant. All positive metrics and actual loaded Core/runtime identities verified; 75,380 timestamped measurements retained. These are single observations, not repeat-based performance proof.

Read-one/changing allocation MB/s is 25.520/26.416/16.049 base/off/on; enumerate/changing is 26.853/27.613/26.482. Duplicate/budget modes use stable primary values. Read-all means the five primary fixture fields, not X-Budget: known-string reuse after warmup leaves room to defer that unread large value. Its low on/read-all/budget rate is not evidence of cheap eager fallback; ignore/budget exceeds the aggregate copy budget. The frozen fixture is retained, not replaced. Correctness tests separately cover exact-budget/fallback behavior.

Supplemental per-run metrics, raw archive and reproduction, all generalized artifact checksums. The README includes all eight cases, errors, exact plans/inputs and commands. The local agent queue was empty and the owned agent stopped after completion.

Historical evidence preserved

At 112166c827fbc38e88f4327675964de15a4470d0, the User-Agent-only 60-run comparison completed 70,130,567 requests with zero bad/socket errors. Changing/ignored median allocation rate was 14.89/14.59/10.35 MB/s base/off/on, with overlapping throughput spreads and read/default-off concerns. Nine separate single-repeat supplements retain 15 baseline enumeration timeouts; an earlier default-off attempt retains 16 timeouts. None is replaced or presented as generalized performance evidence.

Historical raw artifacts and hashes. Existing branch perfboss/lazy-user-agent-poc is retained to preserve continuity.

Discussion and limitations

The generalized implementation, correctness coverage and comparative Crank evidence are delivered; keep this PR draft for discussion. Read/default-off and retained-memory budgets remain unresolved. Cold/low-reuse and isolated client/server follow-ups are limitations before any shipping recommendation, not measurements claimed here. No overall win is claimed.

🤖 Posted by PerfBoss (AI Agent)

davidfowl and others added 4 commits October 21, 2026 19:51
Track the bounded lazy-value experiment in #69962. Preserve owned input storage, eager fallbacks, and decoded-value reuse.

Co-authored-by: Copilot <[email protected]>
Prepare ignored, read, enumerated, changing, and duplicate header cases for #69962. Agent execution remains pending.

Co-authored-by: Copilot <[email protected]>
Use unique fixed-width per-thread values rather than alternating values that could repeat on individual connections. Add the baseline fixture import for reproducible diagnostics.

Co-authored-by: Copilot <[email protected]>
…idence

Record exact source identities, raw measurements, eager-control allocation checks, baseline-matched test failures, socket smoke results and an explicit unrun Crank handoff for #69962.

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Oct 21, 2026
davidfowl and others added 5 commits October 21, 2026 20:19
Verify body-read lifetime through HTTP/2 and actual header-collection pooling through the HTTP/3 in-memory stream harness. These correctness checks do not replace the outstanding Crank measurements in #69962.

Co-authored-by: Copilot <[email protected]>
Document 775 passed and 5 skipped protocol-related functional cases, their exact selection and skip reasons, and related public representation/API discussions. Crank acceptance remains open in #69962.

Co-authored-by: Copilot <[email protected]>
Default named-header ingestion to eager and opt in only from the HTTP/1.1 parser callback. Restore eager HPACK/QPACK paths and verify compressed and literal-name compatibility even with the process switch enabled. Preserve historical results without claiming they measure this revision. Tracks #69962.

Co-authored-by: Copilot <[email protected]>
…ical results

Record 16 cases per source with unchanged baseline shipping code, exact JSON/raw output, fixture identity, uncertainty, and current correctness evidence. Crank remains unrun.

Co-authored-by: Copilot <[email protected]>
@davidfowl davidfowl changed the title POC: opt-in lazy User-Agent materialization in Kestrel POC: HTTP/1.1-only lazy User-Agent allocation in Kestrel Oct 21, 2026
davidfowl and others added 7 commits October 21, 2026 22:55
…ontrol

Record 36 real-socket correctness checks, persistent reuse, loaded Core identity and new DLL hashes. No throughput or Crank claims.

Co-authored-by: Copilot <[email protected]>
Validate resolved localFolder rather than silently benchmarking the configuration-relative payload. Keep original net12 application runtime while local agent/load wrapper use existing net10 tools.

Co-authored-by: Copilot <[email protected]>
Keep original POC runtime and disclose shared client/server limits. Actual POC load results remain pending; local profile question is resolved.

Co-authored-by: Copilot <[email protected]>
…local client

Use short shared TMPDIR and published pinned wrapper upload; avoid stale source caches. Primary repeat matrix is running separately; pilot is not outcome evidence.

Co-authored-by: Copilot <[email protected]>
…nd limits

Preserve all runs, identities, timestamps, rate/GC/CPU/latency distributions and reproduction. Changing unread allocation falls, but shared-host throughput shows no trustworthy overall win; keep read/default-off concerns explicit.

Co-authored-by: Copilot <[email protected]>
Publish all nine single-repeat enumeration/duplicate cases separately from the zero-error primary matrix. Retain the baseline15timeouts without replacement, add artifact checksums, and record owned-agent cleanup.

Co-authored-by: Copilot <[email protected]>
@davidfowl davidfowl changed the title POC: HTTP/1.1-only lazy User-Agent allocation in Kestrel POC: General lazy HTTP/1.1 request-header values Oct 22, 2026
davidfowl and others added 6 commits October 22, 2026 02:37
Own one bounded byte arena, preserve eager protocol/framing controls, wire presence/value/mutation/enumeration surfaces and generated fields, clear discarded bytes, and retain decoded known reuse. Expand correctness and five-header workload; preserve User-Agent-only measurements as historical rather than generalized evidence.

Co-authored-by: Copilot <[email protected]>
… load evidence

Record seven baseline timeouts without attributing them to the feature; preserve raw pilot/results/identity and runner traceback. Fix a final source and disclose record-errors policy for the predetermined full comparison, retaining all cases rather than selecting clean runs.

Co-authored-by: Copilot <[email protected]>
Retain matched binary payloads with licenses and full per-file manifests, original runtime requirement, exact source96def787 and hash,777functional cases plus5skips,96socket requests and complete local execution recipe. Comparative Crank remains in progress; initial timeout failure is separate.

Co-authored-by: Copilot <[email protected]>
…inty

Keep socket errors in all groups, require the full planned completion, preserve per-run sample counts and timestamp windows, and compute paired spreads without request-normalizing allocation rates or inventing singleton deviation.

Co-authored-by: Copilot <[email protected]>
@PureWeen

PureWeen commented Nov 2, 2026

Copy link
Copy Markdown
Member

/review

@PureWeen

PureWeen commented Nov 3, 2026

Copy link
Copy Markdown
Member

/review

@davidfowl davidfowl closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants