Uh oh!
There was an error while loading. Please reload this page.
File.*AllText* optimizations - #58167
Conversation
ghost
commented
Aug 26, 2021
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsThe reduced memory allocations come from lack of The reduced CPU time comes mostly from using bigger buffers and setting file preallocation size.
|
adamsitnik
commented
Aug 26, 2021
@jozkee please let me know if you would like me to separate the refactor from the optimizations |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| { | ||
| if (path == null) | ||
| throw new ArgumentNullException(nameof(path)); | ||
| Validate(path, encoding); |
There was a problem hiding this comment.
It's probably fine, but this does change which exception will be thrown if there are multiple things wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
danmoseley
commented
Aug 26, 2021
I assume no new tests are warranted as it's purely perf, but having touched this code can you see any we maybe are missing? |
…need to store the preamble
…nefit, as it requires additional sys-call(s)
Co-authored-by: Stephen Toub <stoub@microsoft.com>
adamsitnik
commented
Aug 27, 2021
@stephentoub@danmoseley I've added missing tests, which identified a bug, fixed it and updated perf numbers to include Linux numbers as well. On Linux it's now even two times faster for large strings! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
adamsitnik
commented
Oct 12, 2021
I am closing the PR as it's pointless with the regression that has been recently introduced and backported to 6.0 (#59705) |
stephentoub
commented
Oct 12, 2021
stephentoub
commented
Oct 12, 2021
You'd made a bunch of style changes, consolidating input validation, etc. Do you want to keep those? |
It was, because I wanted to clarify how |
# Conflicts: # src/libraries/System.Private.CoreLib/src/System/IO/File.cs
Co-authored-by: David Cantú <dacantu@microsoft.com>
adamsitnik
commented
Oct 14, 2021
I was able to get some nice perf wins anyway (mostly due to using larger buffers which reduced the number of sys-calls). The failures are not related ( |
danmoseley
commented
Oct 14, 2021
Nice! |
kunalspathak
commented
Oct 19, 2021
Ubuntu x64 improvements - dotnet/perf-autofiling-issues#1897 |
kunalspathak
commented
Oct 19, 2021
alpine improvements - dotnet/perf-autofiling-issues#1922 |
kunalspathak
commented
Oct 19, 2021
windows x64 improvements - dotnet/perf-autofiling-issues#1933 |
danmoseley
commented
Oct 19, 2021
woo hoo. also, @kunalspathak@adamsitnik what happened here? it's not obvious to me that this change improved File.Exists -- |
danmoseley
commented
Oct 19, 2021
A curious bimodality that seems to stay in one state for a week or more. I wonder whether iterations within an individual run are stable? I don't see a way to determine from the report. |
AndyAyersMS
commented
Nov 23, 2021
Improvement dotnet/perf-autofiling-issues#1795 (click on full history to see) |
It's interesting that it got both faster and more stable despite still being an IO benchmark. I suspect that it might be caused by using the preallocation size which avoids fragmentation. |
danmoseley
commented
Nov 24, 2021
That is a beautiful graph. Nice. |
jeffhandley
commented
Nov 26, 2021
Wow; it really is! Great work, and I love seeing the data loop closed like this, attributing the improvements to the change. |



The reduced memory allocations come from lack of
StreamWriterandFileStreambuffer allocations.The reduced CPU time comes mostly from using bigger buffers and setting file preallocation size.
Windows
Details
Ubuntu
Details