Use IndexOfAny in StreamReader ReadLine#75646
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsRefactored StreamReader ReadLine/ReadLineAsync to use Span.IndexOfAny dotnet/performance benchmarksBenchmarkDotNet=v0.13.2, OS=Windows 10 (10.0.19044.2006/21H2/November2021Update)
AMD Ryzen 7 3700X, 1 CPU, 16 logical and 8 physical cores
.NET SDK=7.0.100-preview.7.22377.5
[Host] : .NET 7.0.0 (7.0.22.37506), X64 RyuJIT AVX2
Job-QTLAVP : .NET 8.0.0 (42.42.42.42424), X64 RyuJIT AVX2
Job-OYFQVY : .NET 8.0.0 (42.42.42.42424), X64 RyuJIT AVX2
There are regressions in benchmarks with close continuous line-endings (e.g [0,0] which is "\r\n\r\n" repeated), because IndexOfAny will almost always try to use SIMD - since the input buffer is typically large enough to fit in a vector.
|
|
Thank you. There's already a PR doing this, though: |
|
Can't believe I missed it. I clearly need to get better at going over open pull requests! |
No worries at all. We're striving to do better at reducing our open PR count.
Ok. Thanks, again. |
|
@yesmey I know @GrabYourPitchforks has another project currently. If you're interested in looking at the other PR to help nudge it along, that would more probably be welcome. |
Refactored StreamReader ReadLine/ReadLineAsync to use Span.IndexOfAny
dotnet/performance benchmarks
Source
There are regressions in benchmarks with close continuous line-endings (e.g [0,0] which is "\r\n\r\n" repeated), because IndexOfAny will almost always try to use SIMD - since the input buffer is typically large enough to fit in a vector.
I don't know if its a very common scenario though