Repository navigation
cp: stat each copied file fewer times - #16631
KrushnXGIT wants to merge 4 commits into
Conversation
|
Binary size comparison: |
Merging this PR will improve performance by 13.36%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
|
GNU testsuite comparison: |
|
Please check against GNU coreutils 9.12, or master branch as per |
Thanks, re-measured against the GNU 9.12 reference build from |
|
Please drop the merge commit and consider squashing the branch history unless each commit is intended to stand alone. |
|
@codspeedbot fix this regression |
|
Well done. |
I didn't push a fix, because this PR does not cause the regression. The 4 Memory regressions come from a benchmark harness upgrade on Why the memory numbers moved
I could not reproduce the 788.5 KB in CodSpeed Memory mode, because macro runners are not enabled for this organization. Since the plain What you can do
If the next report still shows a memory regression after the rebase, comment this and I'll look into it: Summary
Learnings updated. See what CodSpeed remembers about this repository. Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
1ab81cd to
bd192f2
Compare
Added one to util/check-open-once.sh (the Redundant Open Check job): it copies 10 and then 20 empty files with cp -R under strace, and fails if each extra file costs more than 7 stat calls, or any umask call. Against main it fails with "cp -R made 13 stat calls per copied file, expected at most 7". |
Thanks @xtqqczze , sir sylvestre rebased it. I'll rebase my branches instead of merging main from now on. |
3b103dd to
cfb09bd
Compare
|
Rebased onto main to resolve the conflict with 0df6594: the --remove-destination hard link check keeps this PR's order (the option first, then the stats) and uses main's new paths_are_distinct_entries. The new check is in util/check-open-once.sh, which #16123 rewrites in Rust. @oech3, if yours lands first, I'll port the check there. |
|
/rerun |
cp -Rmakes 26 syscalls per copied file on Linux, 11 of themstatx. GNU 9.12 makes 12 in total. Most of the extra calls look up something already known:lstated every entry, but walkdir already has its type (thelstatcame in with feat(cp): optimize directory copy by caching file checks and refactoring calls #8805).copy_filechecked whether a destination symlink's target exists, and whether the source and destination are hard links, for every file. Those answers are only used when the destination is a symlink, or with--remove-destination.lstated a second time even when it didn't exist the first time.copy_attributeslstated the source even when no attribute is preserved, as with plaincp -R.fstated twice in a row.The second commit reads the umask once for the whole copy instead of with 2
umaskcalls per file.100 dirs × 1000 files on tmpfs, 15 runs each (GNU 9.12 is the reference build from
CONTRIBUTING.md):Output, errors and exit codes match main for
-R,-a,-RL,-RH,-Rp,--preserve=links,-Rl,--sparse=always/never,--reflink=never,--no-preserve=mode,-vand--attributes-only. The tree had symlinks (some dangling), hard links, a FIFO and a sparse file. They also match when copying onto an existing copy with-R,-f,--remove-destination,-n,-u,--backup=numberedand-a. The outcome can only differ when a file appears or disappears during the copy.