Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the HTTP/2 and HTTP/3 path-validation changes.
No open issues 🎉
What changed in this PR
Optimizes Kestrel’s HTTP/2 and HTTP/3 :path validation by skipping byte conversion and decoding for common paths without percent encoding or dot segments, while retaining the existing fallback.
Changes:
- Adds matching fast paths for HTTP/2 and HTTP/3, with separate validation for paths with and without queries.
- Extends functional tests for plain paths, normalization, encoding, and invalid characters.
- Adds a pooled HTTP/2 stream benchmark covering header processing and request validation.
| File | Description |
|---|---|
| src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3StreamTests.cs | Adds plain-path and query-bearing decoding and normalization cases. |
| src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs | Adds path cases and invalid-character rejection coverage with a query. |
| src/Servers/Kestrel/perf/Microbenchmarks/Http2/Http2StreamHeadersBenchmark.cs | Benchmarks HTTP/2 header processing across three request targets. |
| src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs | Adds the HTTP/3 path-validation fast path. |
| src/Servers/Kestrel/Core/src/Internal/Http2/Http2Stream.cs | Adds the equivalent HTTP/2 path-validation fast path. |
Review effort: Balanced
|
Retriggered CI with an empty commit (873e2af). The failures on 5e625ab look unrelated to this change:
🤖 Posted by ASP.NET Core Perf 2 (AI Agent) |
|
/review |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Merge assessment (Nov 29)Verdict: Do not merge this head. It conflicts with current main and the Nov 26 path-validation change on main makes the prior encoding/behavior parity claim inapplicable to a straightforward rebase. The author acknowledged both open maintainer requests on Nov 29, but no rebase or code fix has been pushed. The old green checks and H2 benchmark cannot validate a revised implementation.
Reasons to merge: The original three BDN rounds show a substantial H2 hot-path gain without additional allocations; accepted clean-path requests should benefit on both protocols once parity is preserved. Reasons not to merge yet: Current-main changes overlap the shortcut and tests, GitHub reports a conflict, and a direct rebase would bypass the tightened character-range check for some paths. Both reviewer requests remain open; the benchmark covers H2 only and the exact-head CI does not exercise a revised implementation. What would change this verdict: Rebase and preserve the current 🤖 Posted by ASP.NET Core Perf 2 (AI Agent) |
|
ASP.NET Core Perf 2 finished triaging and acknowledging this PR’s reviewer feedback; code fixes remain pending. 🤖 Posted by ASP.NET Core Perf 2 (AI Agent) |
|
ASP.NET Core Perf 2 finished the review fixes; the published branch is awaiting CI and maintainer review. 🤖 Posted by ASP.NET Core Perf 2 (AI Agent) |
Skip narrowing the :path value to bytes and running PathDecoder when the path has no percent-encoding and no dot segments. Inputs that don't match the fast path, including all invalid ones, use the existing code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the HTTP/3 import set minimal and cover the printable ASCII boundary with and without a query. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
873e2af to
f28560b
Compare
Fast path for HTTP/2 and HTTP/3 :path validation
Description
Avoid narrowing
:pathto bytes and callingDecodePathfor clean HTTP/2 and HTTP/3 paths. A sharedPathDecoder.TryGetUnmodifiedPathhandles paths without percent escapes or dot segments and with only0x20..0x7Echaracters (the same range accepted by the current-main narrowing loop). Without a query it reusesRawTarget; with a query it creates the path substring. All other paths retain existing validation, escaping, normalization and protocol-specific errors. This changes no public API.Benchmark
Http2StreamHeadersBenchmarkresets and processes eight request headers, then callsTryParseRequest. BenchmarkDotNet on the same machine and .NET 12 runtime, Release, against current mainb5afc478ceand this rebased branch. The default throughput job (separate A/B runs) yielded://api/products/12345/shop/category/electronics/laptops/item-12345?ref=homepage&utm_source=newsletterA second ShortRun job in the same executions gave 161.9→169.3 ns (
/), 186.6→167.0 ns (short path), 228.7→200.2 ns (query path). The root case is inconclusive; the two longer paths improve in both jobs. These are HTTP/2 measurements; HTTP/3 is behavior-tested but not independently benchmarked.Tests
The rebased in-memory HTTP/2+HTTP/3 path tests check raw target, path and query for clean paths,
/.b, dot segments, percent escapes, query strings and printable-ASCII boundary, and assert rejection for control, DEL and non-ASCII characters with and without a query. Focused test run: 64 passed, 0 failed. Kestrel InMemory.FunctionalTests project builds with 0 warnings and 0 errors.🤖 Posted by ASP.NET Core Perf 2 (AI Agent)