Repository navigation
Reuse Http3RawFrame across pooled HTTP/3 streams - #70118
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
davidfowl
requested review from
BrennanConroy,
SamMonoRT and
halter73
as code owners
October 30, 2026 16:53
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the HTTP/3 frame reuse change, which reduces per-request allocations.
No open issues 🎉
What changed in this PR
Reduces per-request allocations in Kestrel’s HTTP/3 processing by reusing a frame object across pooled stream requests.
Changes:
- Adds a readonly
Http3RawFramefield toHttp3Stream, replacing the per-request allocation. - Resets the frame’s type and remaining length before processing each request.
| File | Description |
|---|---|
src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs |
Reuses the incoming frame across pooled requests and resets its state at request start. |
Review effort: Balanced
Member
|
/review |
Contributor
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reuse Http3RawFrame across pooled HTTP/3 streams
Description
Motivation
Http3Stream.ProcessRequestAsyncallocates a newHttp3RawFramefor every request, even though HTTP/3 request streams are pooled and reused. HTTP/2 already reuses a single frame per connection.Change
Http3Streamgets areadonly Http3RawFrame _incomingFramefield.ProcessRequestAsyncresets itsTypeandRemainingLengthat the start of each request and then reuses it.TryReadFrameoverwrites the frame's state for every frame it reads. The diff is one file, +5/−1.Benchmarks
Http3ConnectionEmptyBenchmark.MakeRequestfromsrc/Servers/Kestrel/perf/Microbenchmarks, with MemoryDiagnoser.Environment:
--config perflab(InProcess),--warmupCount 5 --iterationCount 15, plus the JSON exporter to get exact bytes, because the table rounds to KB.BytesAllocatedPerOperation:
Mean time:
MakeRequest, ResponseDataLength=0) gives main 6052.5 / 6054.4 B/op and the PR 6017.1 / 6015.9 B/op, i.e. −37 B per request.Tests
InMemory.FunctionalTests(filter Http3): 236 passed, 0 failed.Microsoft.AspNetCore.Server.Kestrel.Core.Tests: everything passed except 13AddressBinderTests/KestrelServerTestsIPv6 tests that fail identically onmain, because the test machine has no IPv6.Benchmark (3 interleaved rounds)
Existing
Http3ConnectionEmptyBenchmark.MakeRequest(src/Servers/Kestrel/perf/Microbenchmarks/Http3).Environment: AMD EPYC 9V74, 2 vCPU (container), Ubuntu 24.04; .NET SDK 12.0.100-alpha.1.26521.103, .NET 12.0.0 (12.0.26.52911); BenchmarkDotNet v0.13.0
--config perflab(InProcess, MemoryDiagnoser), WarmupCount=3, IterationCount=10. "main" is the merge base4f556f73a6. Both builds use the same benchmark source, and runs were interleaved main, PR, main, PR, main, PR. Each cell shows mean / allocated per operation; allocation figures are exact bytes from the CSV exporter.ResponseDataLengthvalues.Http3RawFrameper request. But that's under 1% of the ~6 KB per request, and BenchmarkDotNet's per-operation figure here includes background allocations. One pair (128 B, round 2) went the other way by 355 B.🤖 Posted by ASP.NET Core Perf 2 (AI Agent)