-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change if order to improve FileStream perf for cases when both buffers are of the same size #51489
Conversation
Tagging subscribers to this area: @carlossanlop Issue DetailsWhen nothing has been written to the buffer yet ( This is ofc an edge case, but since we already have a benchmark for it and it's relatively small change we should IMO change it. See the
|
src/libraries/System.Private.CoreLib/src/System/IO/Strategies/BufferedFileStreamStrategy.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/Strategies/BufferedFileStreamStrategy.cs
Show resolved
Hide resolved
@adamsitnik / @carlossanlop / @jozkee -- do we want to get this in for Preview 5 with the other FileStream follow-up work? |
@carlossanlop @jozkee I've added a comment that hopefully explains why bypassing the cache is possible in this particular scenario. PTAL Updated perf numbers:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
When nothing has been written to the buffer yet (
_writePos == 0
) and the size of the buffer passed toWriteAsync
is the same as internalFileStream
buffer, we should omit buffering logic and just call the actual strategy directly.This is ofc an edge case, but since we already have a benchmark for it and it's relatively small change we should IMO change it.
See the
Allocated
column: