-
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
Improve File.Move performance #65092
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsSimilarly to what I did in #63675 for
The native sys-call that is called by The following condition can most likely avoid the check as well: runtime/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs Lines 225 to 229 in 71393d0
(we could check if the source file is the same file/drive as destination only after we verify that destination exists. In cases where destination does not exists there is no need of doing that) While working on this it would be nice to unify The contributor who is willing to work on this issue needs to contribute
|
As described in #58240 you can assign the issue to me. But I think I'll just start working on that issue in about 1-3 weeks. |
@deeprobin Please ping me then and I'll assign you. Thanks! |
@deeprobin ping |
@rhuijben Thank you. |
done! |
I think the PR will come at the end of this week or next week. |
@adamsitnik I know it's not perfect yet, but I noticed test failures on Windows right after I removed the check.
Benchmark Results.NET 7.0 Preview 4
deeprobin/runtime#issue-65092
(Why is there a regression - I only removed the exists-check) |
The issue is that you get a different error than before, which is a regression. I would like to see an attempt to check for this case after the error, so callers see the expected error when there is an error, but the code for the non-error case is faster than before, by avoiding the performance penalty of another sys all. Personally I wouldn't care too much about one specific error or another one, as that difference is quite common in platform agnostic code... But in this case backwards compatibility matters the most. |
Similarly to what I did in #63675 for
Directory.Move
there is most likely no need to perform a check whether source file exists inruntime/src/libraries/System.Private.CoreLib/src/System/IO/File.cs
Line 417 in 71393d0
The native sys-call that is called by
FileSystem.MoveFile
is most likely going to fail in such situations. We should just handle theFileSystem.MoveFile
failure and map it to the same (existing) exception on both Windows and Unix.The following condition can most likely avoid the check as well:
runtime/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Lines 225 to 229 in 71393d0
(we could check if the source file is the same file/drive as destination only after we verify that destination exists. In cases where destination does not exists there is no need of doing that)
While working on this it would be nice to unify
File.Move
andFileInfo.MoveTo
and fix #35122The contributor who is willing to work on this issue needs to contribute
File.Move
benchmarks to the https://github.com/dotnet/performance repository. TheFile
benchmarks can be found here. Here you can find docs that explain how to run the benchmarks against local build of dotnet/runtime.The text was updated successfully, but these errors were encountered: