Repository navigation
du: dedupe reflink bytes - #10081
du: dedupe reflink bytes#10081aaron-ang wants to merge 8 commits into
Conversation
|
GNU testsuite comparison: |
afa86ce to
44ae977
Compare
|
GNU testsuite comparison: |
1ef975e to
5bc43b7
Compare
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 7.19%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | cp_recursive_deep_tree[(120, 4)] |
532.7 KB | 699.2 KB | -23.82% |
| ❌ | Simulation | du_deep_tree[(100, 3)] |
1 ms | 1.1 ms | -5.9% |
| ⚡ | Memory | du_summarize_balanced_tree[(5, 4, 10)] |
467.7 KB | 419.4 KB | +11.51% |
| 🆕 | Memory | du_dedupe_reflinks_wide_tree[(5000, 500)] |
N/A | 1 MB | N/A |
| 🆕 | Simulation | du_dedupe_reflinks_wide_tree[(5000, 500)] |
N/A | 12.8 ms | N/A |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing aaron-ang:du-reflink-count (ade4a5c) with main (49a56e2)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
5bc43b7 to
92b8b94
Compare
d28fb14 to
e27dc67
Compare
|
GNU testsuite comparison: |
|
|
||
| #[cfg(not(windows))] | ||
| use regex::Regex; | ||
| #[cfg(target_os = "linux")] |
There was a problem hiding this comment.
Somehow this is the first time I've seen this notation, this is really nice and would be nice to cleanup our other cfg code
|
Just to clarify that my understanding matches yours. This would be extending past GNU's capabilities instead of matching GNU's capabilities right? Given that its a big change I imagine it would be something that would be reviewed after the issues with GNU compatibility are sorted out |
| @@ -1094,6 +1206,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { | |||
|
|
|||
| // Check existence of path provided in argument | |||
| let mut seen_inodes: HashSet<FileInfo> = HashSet::new(); | |||
| let mut seen_shared_extents: HashSet<SharedExtentKey> = HashSet::new(); | |||
There was a problem hiding this comment.
I think this is a pre-existing bug, theres another open PR about moving that seen_inodes out of this loop so that when you pass multiple file names it can deduplicate. Ideally this would be moved outside of the loop too
There was a problem hiding this comment.
I've updated it.
yea that's right. |
1513fa4 to
9442287
Compare
adf4e6a to
0cfb7cc
Compare
|
GNU testsuite comparison: |
Parallel FIEMAP — bench resultsImplemented mpsc and rayon variants of the dedup FIEMAP loop to evaluate cben's suggestion (10081#discussion_r... — issue comment). Compared against the current serial path on tmpfs/ext4 (aarch64, Linux 6.17, warm cache). Micro-bench: isolated FIEMAP loop (5000 files / 500 dirs, 100 samples, divan)
Rayon wins when only the FIEMAP loop is measured. End-to-end:
|
| integration | median | vs serial |
|---|---|---|
| serial | 46.3 ms | — |
| rayon | 142.3 ms | 3× slower |
| mpsc | 296.0 ms | 6× slower |
The parallel integrations need a pre-pass to collect (path, dev_id) for regular files (so workers can run concurrently), which doubles the per-file lstat cost. On tmpfs/ext4 where FIEMAP is cheap, that overhead dominates and serial wins.
On btrfs (cben's 5× scenario) the math may flip — FIEMAP is the bottleneck there, not stat. I don't have a btrfs system to verify. Keeping serial in this PR; leaving the parallel paths as a follow-up once someone can bench on btrfs.
What was tested
dedupe::extents_for(single-file FIEMAP)dedupe::parallel_extents(rayon par_iter)dedupe::parallel_extents_mpsc(Mutex-shared input queue, N=available_parallelism workers, single accumulator drain)- Integration via per-directory pre-pass + batch FIEMAP
The integration refactor + extra module were reverted; only serial inline FIEMAP ships in this PR (current HEAD).
|
hi @cben, quick map from your points to changes:
CI is green on the current HEAD. Happy to iterate further if you spot anything else. |
|
@aaron-ang Are you interested in adding fiemap wrapper to uucore also for other utils e.g. |
|
@sylvestre Do you still want to have this extension? |
|
the PR is hard to understand with the very long comments :( what is the tldr and status ? |
|
This PR adds an expention to avoid counting size consumed by reflink 2+ times in my understanding. |
|
maybe ? |
| pub const EXCLUDE_FROM: &str = "exclude-from"; | ||
| pub const FILES0_FROM: &str = "files0-from"; | ||
| pub const VERBOSE: &str = "verbose"; | ||
| pub const DEDUPE_REFLINKS: &str = "dedupe-reflinks"; |
There was a problem hiding this comment.
| pub const DEDUPE_REFLINKS: &str = "dedupe-reflinks"; | |
| pub const REFLINK: &str = "reflink"; |
I think du --reflink is enough.
There was a problem hiding this comment.
i disagree. unlike cp where --reflink makes sense as an option (intuitively means copy reflinks also), for du it is not obvious how reflink applies, since it is also not in GNU convention.
0cfb7cc to
32125c9
Compare
|
I think this is |
|
I am wondering if trying |
|
|
sorry but it needs to be rebased |
Also correct the wide-tree bench comment: its files are empty, so it measures the per-file open, not FIEMAP.
ade4a5c to
72312a3
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Files with no allocated blocks have no extents to claim, so do not open them. Record each inode before querying its extents, so a file that fails is reported once instead of again for each later operand or hard link.
With --dedupe-reflinks, a file that cannot be opened for reading, or whose filesystem does not support FIEMAP, kept being reported as an error and dropped from the totals. Plain du only needs stat, so count such files at their full size instead, matching the output without the option. Also move the new reflink error messages into the locale files.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Closes #3906.
Adds an opt-in
--dedupe-reflinksflag todu(Linux only). It walks each regular file's extents with the FIEMAP ioctl and counts a shared{device, physical, length}extent only for the first file that references it. Directory entries are visited in name order so results are repeatable; command-line operands keep their given order. The flag conflicts with--apparent-size,--bytes,--inodesand--count-links. Default behavior is unchanged.Only exact extent matches are deduplicated, so partially overlapping CoW extents are still counted more than once. Extents with no reliable physical address (inline, delayed allocation, etc.) are not deduplicated. Files that cannot be read, or that live on a filesystem without FIEMAP (tmpfs, NFS), are counted at full size, the same as without the flag. FIEMAP adds syscalls per file, which is why the flag is opt-in;
du_dedupe_reflinks_wide_treeanddu_dedupe_reflink_clonesindu_bench.rsmeasure the cost.