Skip to content
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

FileSystem.Unix: CopyFile: use copy_file_range on Linux. #64264

Merged
merged 7 commits into from
Jan 31, 2022

Conversation

tmds
Copy link
Member

@tmds tmds commented Jan 25, 2022

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jan 25, 2022
@ghost
Copy link

ghost commented Jan 25, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #30156.

@adamsitnik ptal.

cc @lpereira @filipnavara

Author: tmds
Assignees: -
Labels:

area-System.IO, community-contribution

Milestone: -

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmds could you please provide benchmark numbers that justify the change?

@tmds
Copy link
Member Author

tmds commented Jan 27, 2022

@tmds could you please provide benchmark numbers that justify the change?

The main benefit is that unlike sendfile this is a file system operation, and the filesystem may optimize for it.

When I copy a file over SMB using the existing .NET sendfile implementation, all the data passes through my machine.

$ time dotnet /tmp/console/bin/Debug/net6.0/console.dll /tmp/share/Fedora.iso /tmp/share/Fedora_sendfile.iso

real	0m29.196s
user	0m0.051s
sys	0m1.748s

With copy_file_range it does not.

$ time ./corerun /tmp/console/bin/Debug/net6.0/console.dll /tmp/share/Fedora.iso /tmp/share/Fedora_cfr.iso

real	0m0.591s
user	0m0.097s
sys	0m0.161s

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, big thanks for taking care of all of the edge cases! 👍

@adamsitnik adamsitnik added this to the 7.0.0 milestone Jan 28, 2022
@adamsitnik adamsitnik merged commit 215c328 into dotnet:main Jan 31, 2022
@adamsitnik adamsitnik added the tenet-performance Performance related issue label Jan 31, 2022
@Thefrank
Copy link
Contributor

Thefrank commented Feb 1, 2022

This already got merged, but FreeBSD starting with 13.0-STABLE also has copy_file_range: https://www.freebsd.org/cgi/man.cgi?query=copy_file_range&sektion=2&format=html

@ghost ghost locked as resolved and limited conversation to collaborators Mar 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO community-contribution Indicates that the PR has been added by a community member tenet-performance Performance related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SystemNative_CopyFile() should use copy_file_range() in Linux
7 participants