Repository navigation
Conversation
…'s request line parser Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The frozen review bundle, prior feedback, and independent guide reviews were unavailable, preventing completion of the required review process and verification of revision provenance.
No open issues 🎉
What changed in this PR
Optimizes Kestrel’s HTTP/1.1 request-line parsing by replacing the scalar query-string terminator search with a vectorized span search, preserving the resulting offset.
Changes:
- Uses
ReadOnlySpan<byte>.IndexOf(ByteSpace)to locate the query’s ending space. - Adds long- and short-query benchmarks to measure performance.
| File | Description |
|---|---|
src/Servers/Kestrel/perf/Microbenchmarks/HttpParserBenchmark.cs |
Adds long- and short-query request parsing benchmarks. |
src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs |
Replaces the query scan loop with IndexOf, retaining the no-space fallback. |
Review effort: Balanced
…tionTest) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pushed an empty commit to retrigger CI. Both failures look unrelated to this change, which only affects how the HTTP/1.1 request-line parser finds the end of the query string:
🤖 Posted by ASP.NET Core Perf 2 (AI Agent) |
…_Async) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
On the retriggered run, 🤖 Posted by ASP.NET Core Perf 2 (AI Agent) |
|
/review |
HttpParser.TryParseRequestLinefinds the end of the query string with a scalar byte-by-byte loop that looks for the space before the HTTP version. This PR replaces that loop withReadOnlySpan<byte>.IndexOf(ByteSpace), which is vectorized. The resultingoffsetis identical: the index of the first space, orrequestLine.Lengthif there is none. The path portion before it already usesIndexOfAny.Benchmarks
Local BenchmarkDotNet (InProcess, MemoryDiagnoser), 2 vCPU VM, 4 interleaved base/PR rounds. Two benchmarks are new in
HttpParserBenchmark:QueryString:/api/products/search?q=...&page=2&pageSize=24, a 121-byte queryShortQueryString:/api/items?id=42Existing
HttpParserBenchmarkcases (PlaintextTechEmpower, JsonTechEmpower, LiveAspNet, Unicode, MultispanUnicodeHeader) have no query string and are unchanged within noise over 3 rounds. No allocations in any case.Tests
Microsoft.AspNetCore.Server.Kestrel.Core.Testsfiltered to HttpParserTests, Http1ConnectionTests, StartLine, HttpRequestLine and Target: 7194 passed, 0 failed.No API / behavior change
PublicAPI.*.txtchanges and no new APIs.🤖 Posted by ASP.NET Core Perf 2 (AI Agent)