Improve performance with copy_file_range(2)#161
Merged
sylvestre merged 2 commits intouutils:mainfrom Sep 30, 2025
Merged
Conversation
This is more realistic and allows to benchmark copy_file_range(2) performance.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #161 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 13 13
Lines 2729 2882 +153
Branches 240 254 +14
======================================
- Misses 2729 2882 +153
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7986758 to
2485a53
Compare
4b07a7c to
b9f4634
Compare
On file systems supporting reflinks or extent remapping, such
as XFS, Btrfs, NFS, regions of files that are not modified are
processed without any copying — with O(1) cost.
While at it:
- Correct the use of write(2) to handle partial writes and
report appropriate errors.
- Improve buffer sizing.
These are the benchmark results
no-op-short copy-file-range is 1.17 times faster than main
access-log-no-op copy-file-range is 2.91 times faster than main
access-log-no-subst copy-file-range is 1.56 times faster than main
access-log-subst copy-file-range is 1.03 times faster than main
access-log-no-del copy-file-range is 1.59 times faster than main
access-log-all-del copy-file-range is 1.06 times faster than main
access-log-translit copy-file-range is 1.05 times faster than main
access-log-complex-sub copy-file-range is 1.04 times faster than main
access-log-append copy-file-range is 1.05 times faster than main
remove-cr copy-file-range is 1.03 times faster than main
genome-subst copy-file-range is 1.08 times faster than main
number-fix copy-file-range is 1.03 times faster than main
long-script main is similarly fast as copy-file-range
hanoi main is 1.03 times faster than copy-file-range
factorial copy-file-range is 1.03 times faster than main
On suported file systems (XFS, BTRFS), output files with no or few in-place
modifications share large blocks with the input file, as can be seen
in the following example.
$ xfs_io -c 'fiemap -v' lines.txt
lines.txt:
EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS
0: [0..857199]: 11917304..12774503 857200 0x2000
1: [857200..857207]: 12774504..12774511 8 0x1
b9f4634 to
65d3197
Compare
Contributor
|
ready for review ? :) |
Collaborator
Author
|
@sylvestre yes, ready, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.