Repository navigation
Reduce read-ahead buffer allocation in WebSocket keep-alive tests - #136917
Merged
Merged
Conversation
Use a 4 KiB read-ahead buffer instead of allocating 64 MiB per endpoint for the long-delay test. Preserve the existing heartbeat interval, Pong deadline, and state assertions. Cover empty messages and receive-buffer boundaries across the loopback variants. The reduced allocation removes avoidable GC pressure; it does not establish that the historical CI abort is eliminated. Co-authored-by: Copilot App <[email protected]>
Keep the change scoped to reducing the existing helper buffer, as requested. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
MihaZupan
approved these changes
Nov 3, 2026
wfurt
approved these changes
Nov 3, 2026
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.
Reduce
ReadAheadWebSocket's scratch receive buffer from 64 MiB to 4 KiB. Its existing callers exchange 1-byte and 6-byte messages, so allocating 128 MiB across the two endpoints is unnecessary. The helper already supports partial receives and queues received data separately.This is test-only allocation hardening. The keep-alive interval, Pong timeout, and assertions are unchanged. It is not a proven resolution of the historical keep-alive CI failure.
A focused BenchmarkDotNet allocation benchmark measured 64 MiB buffers at 4.723 ms and 65,536.68 KiB allocated, versus 4 KiB buffers at 0.664 us and 4.02 KiB allocated. Under a 192 MiB managed heap limit, three original test runs triggered 1, 2, and 2 Gen-2 collections; three changed runs triggered none. These measurements do not establish that GC caused the CI failure.
Validation
Commands ran from the isolated worktree through an owned
X:shortcut, using Debug libraries/tests with Release CoreCLR. Full CI Release-library configuration was not run.X:\build.cmd clr+libs -rc release— passed; clean baseline, zero warnings/errors.X:\.dotnet\dotnet.exe build src\libraries\System.Net.WebSockets.Client\tests\System.Net.WebSockets.Client.Tests.csproj /t:test /p:RuntimeConfiguration=Release /p:Outerloop=true "/p:XUnitOptions=-method System.Net.WebSockets.Client.Tests.KeepAliveTest_*Loopback.KeepAlive_LongDelayBetweenSendReceives_Succeeds -maxthreads 2"— passed: 10 tests, zero failures or skips.X:\.dotnet\dotnet.exe build src\libraries\System.Net.WebSockets.Client\tests\System.Net.WebSockets.Client.Tests.csproj --no-restore /t:test /p:testnobuild=true /p:RuntimeConfiguration=Release— passed: 685 total, 663 passed, 22 existing skips, zero failures.Note
This PR description and change were prepared with GitHub Copilot.