[QUIC] Do not allocate exception if it might not be used#127526
[QUIC] Do not allocate exception if it might not be used#127526MihaZupan merged 1 commit intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
There was a problem hiding this comment.
Pull request overview
Reduces avoidable allocations on the QUIC stream shutdown path by preventing creation of an OperationAborted QuicException when it cannot be observed (because the stream start task source is already completed). This aligns with the perf investigation in #127455 and targets the high-frequency shutdown event path for HTTP/3 server scenarios.
Changes:
- Guard
_startedTcs.TrySetException(ThrowHelper.GetOperationAbortedException())behind_startedTcs.IsCompletedto avoid allocating an exception that would be ignored. - Preserve existing shutdown completion semantics while reducing handled exception churn.
rzikm
left a comment
There was a problem hiding this comment.
LGTM. I assume you looked at other places where we might allocate exceptions unnecessarily?
|
Yep, the only other place interesting was connection shutdown. But we still need it to complete the accept queueu there, so I'm pretty sure this PR is the only relevant place. |
|
/ba-g #127500 |
Fixes #127455


Validation manual on the repro code, before:
after (no more
QuicException):