-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(cp): optimize directory copy by caching file checks and refactoring calls #8805
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
Conversation
|
please add a benchmark testing this in a separate PR |
|
GNU testsuite comparison: |
CodSpeed Performance ReportMerging #8805 will improve performances by 4.06%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
add #8807 |
|
Environment: hyperfine 1.19.0, binaries built via cargo build --release (multicall at target/release/coreutils); benchmark inputs copied from docs into target/tmp/cp_bench_src. Command setup: hyperfine --warmup 5 --runs 50 --prepare "rm -rf target/tmp/cp_bench_dst" "/bin/cp -R target/tmp/cp_bench_src target/tmp/cp_bench_dst" "target/release/coreutils cp -R target/tmp/cp_bench_src target/tmp/cp_bench_dst" --export-json target/tmp/cp_benchmark.json. Results: /bin/cp mean 17.2 ms (σ 0.9 ms, min 15.3 ms, max 20.2 ms); coreutils cp mean 10.1 ms (σ 0.5 ms, min 9.24 ms, max 11.3 ms); both commands exited with status 0 in all 50 runs. Relative performance: target/release/coreutils cp ran 1.71 ± 0.12 times faster than /bin/cp on this workload. |
…calls - Add `target_is_file` field to Context to avoid repeated `stat` calls on target - Refactor `copy_direntry` to accept `&Entry` and additional bool params for symlink/directory handling - Use cached value and local variables for cleaner access to entry properties - Pass `created_parent_dirs` to `copy_file` for improved directory creation tracking This reduces filesystem overhead in cp operations when copying directories.
|
GNU testsuite comparison: |

feat: optimize directory copy by caching file checks and refactoring calls
target_is_filefield to Context to avoid repeatedstatcalls on targetcopy_direntryto accept&Entryand additional bool params for symlink/directory handlingcreated_parent_dirstocopy_filefor improved directory creation trackingThis reduces filesystem overhead in cp operations when copying directories.