Repository navigation
Conversation
Use the reader cancellation token directly when the caller token cannot cancel, retaining a linked source when both tokens participate. BenchmarkDotNet measured 64 B to 0 B per read and 17.1% lower elapsed time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22aae13c-50b4-4b0c-aee0-5a21e2b562c5
|
I pushed an update to reuse a vs-threading extension method. I expected/hoped the perf win would be roughly the same, but with slightly less code and avoiding allocations in even more cases. On my machine... Before (main)
After (this PR with my extra commit)
|
|
@karpinsn Thanks for your PR! |
Nice! I wasn't super happy with the style of the code before, this makes it so much cleaner. Thanks! |
Summary
CancellationTokenSourcewhenStreamPipeReader.ReadAsyncreceives a non-cancellable caller token.CancelPendingRead, caller cancellation, and a representative benchmark.Performance
BenchmarkDotNet, .NET 8, 15 iterations with baseline/candidate/baseline:
Validation
StreamUseStrictPipeReaderTests.ReadAsync_*: 10 passed across net8.0 and .NET Framework