-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
CreateDirectory: eliminate some syscalls. #58799
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsThis eliminates three syscalls per One is the initial check if the directory exist. The other two are eliminating by using When Similar changes can be made to the Windows implementation. @adamsitnik @stephentoub ptal.
|
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.
Looks good to me, but I'd like a secondary review from @dotnet/area-system-io.
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
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.
Overall LGTM, but it would be great to refactor the code a little bit and if it's safe replace List<string>
with List<int>
@tmds thank you for another great contribution!
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
@adamsitnik thanks for the review! I've addressed your comments. |
8832768
to
0a03e35
Compare
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, again thank you @tmds !
@tmds @adamsitnik just for completeness, can we get perf numbers before and after this change? |
Is there some place we can see the diff on the continuous benchmarking of the dotnet/performance repo? |
https://pvscmdupload.blob.core.windows.net/reports/allTestHistory/TestHistoryIndexIndex.html But the existing Directory APIs benchmarks are very noisy: https://pvscmdupload.blob.core.windows.net/reports/allTestHistory%2frefs%2fheads%2fmain_x64_ubuntu%2018.04%2fSystem.IO.Tests.Perf_Directory.CreateDirectory.html |
The change wasn't run by the benchmarks yet. Let's see if we can see it in a couple of days. @adamsitnik what generates this website? Is it part of BenchmarkDotNet? |
It's strange, our automation is supposed to run at least few times a day.
it's closed source tool maintained by @DrewScoggins |
Long story short the data on the test history index page only updates about once a day, because it takes about a day to generate. I am looking to make some changes to greatly reduce the time it takes to generate them, but for now that is where we are. As a result they can sometimes be a little behind. I went ahead and generated a report for just the Directory tests, and though one is marked as a regression, it looks like just noise in the test. I don't see any significant regression or improvement as the result of this change. Report |
do we need an up for grabs issue to do the same for Windows? |
I've created #61954. |
thanks. |
This eliminates three syscalls per
Directory.CreateDirectory
when the path doesn't exist.One is the initial check if the directory exist.
The other two are eliminating by using
mkdir
to check parent directory existence.Instead of finding the first parent that exist using
stat
, we now end up creating the first parent that doesn't exist.When
Directory.CreateDirectory
is called with a path that does exist, we are now making two syscalls instead of one.If we want, we can avoid that regression by keeping the initial existence check. That costs us a syscall in the non-exists case.
A user can also avoid it by calling
Directory.Exists
before callingDirectory.CreateDirectory
.Similar changes can be made to the Windows implementation.
@adamsitnik @stephentoub ptal.