Uh oh!
There was an error while loading. Please reload this page.
CreateDirectory: eliminate some syscalls. - #58799
Conversation
ghost
commented
Sep 8, 2021
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.
|
jeffhandley
left a comment
There was a problem hiding this comment.
Looks good to me, but I'd like a secondary review from @dotnet/area-system-io.
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
left a comment
There was a problem hiding this comment.
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!
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.
tmds
commented
Nov 18, 2021
@adamsitnik thanks for the review! I've addressed your comments. |
8832768 to
0a03e35Compare
adamsitnik
left a comment
There was a problem hiding this comment.
LGTM, again thank you @tmds !
carlossanlop
commented
Nov 18, 2021
@tmds@adamsitnik just for completeness, can we get perf numbers before and after this change? |
tmds
commented
Nov 19, 2021
Is there some place we can see the diff on the continuous benchmarking of the dotnet/performance repo? |
adamsitnik
commented
Nov 19, 2021
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? |
adamsitnik
commented
Nov 19, 2021
It's strange, our automation is supposed to run at least few times a day.
it's closed source tool maintained by @DrewScoggins |
DrewScoggins
commented
Nov 19, 2021
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 |
tmds
commented
Nov 22, 2021
danmoseley
commented
Nov 22, 2021
do we need an up for grabs issue to do the same for Windows? |
tmds
commented
Nov 23, 2021
I've created #61954. |
danmoseley
commented
Nov 24, 2021
thanks. |

This eliminates three syscalls per
Directory.CreateDirectorywhen the path doesn't exist.One is the initial check if the directory exist.
The other two are eliminating by using
mkdirto 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.CreateDirectoryis 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.Existsbefore callingDirectory.CreateDirectory.Similar changes can be made to the Windows implementation.
@adamsitnik@stephentoub ptal.