Skip to content

shred: add sector-phase patterns and Pattern::from_code - #13694

Open
sankalpsthakur wants to merge 2 commits into
uutils:mainfrom
sankalpsthakur:fix/11611-shred-distribution
Open

shred: add sector-phase patterns and Pattern::from_code#13694
sankalpsthakur wants to merge 2 commits into
uutils:mainfrom
sankalpsthakur:fix/11611-shred-distribution

Conversation

@sankalpsthakur

@sankalpsthakur sankalpsthakur commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Prep for #11611. Pattern model + sector-phase write only.

  • Pattern { bytes, flip_sector } and from_code (bit 0x1000)
  • Write path XOR first byte of each 512B sector with 0x80
  • Pass scheduler unchanged (legacy path)

Follow-ups: #13699 genpattern, #13700 residual-entropy (Fixes #11611).

Test: cargo test -p uu_shred --lib and cargo test --test tests test_shred

AI-assisted; I reviewed the diff.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)

@codspeed-hq

codspeed-hq Bot commented Aug 1, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.38%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 343 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_deep_tree[(100, 3)] 2.6 ms 2.7 ms -3.68%
Simulation cksum_crc32b 40.9 ms 39.7 ms +3.03%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sankalpsthakur:fix/11611-shred-distribution (7c9b66b) with main (0c8a3c7)

Open in CodSpeed

Footnotes

  1. 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.

@sylvestre

Copy link
Copy Markdown
Contributor

This is a way too big patch. Please ask your llm to make it shorter

@sankalpsthakur
sankalpsthakur force-pushed the fix/11611-shred-distribution branch from 5380872 to f662966 Compare August 1, 2026 11:55
@sankalpsthakur

Copy link
Copy Markdown
Contributor Author

Slimmed the patch for review: same fix (Gutmann pass groups + sector-phase patterns + residual-entropy scheduling), but dropped verbose comments/helpers and extra unit tests. Diff is now +258/−222 (was +477/−202).

@sylvestre

Copy link
Copy Markdown
Contributor

Removing tests isn't the right approach

Splitting it into several PR yes

@sankalpsthakur sankalpsthakur changed the title shred: match GNU overwrite pass distribution shred: add sector-phase patterns and Pattern::from_code Aug 1, 2026
@sankalpsthakur
sankalpsthakur force-pushed the fix/11611-shred-distribution branch from f662966 to 7a59857 Compare August 1, 2026 12:16
@sankalpsthakur

Copy link
Copy Markdown
Contributor Author

Agreed - I will split instead of dropping tests. Plan: (1) Pattern model + sector-phase write path, (2) genpattern / pass-group scheduler, (3) residual-entropy --random-source + full distribution regressions. This PR is now (1) only. Stacked PRs next; only the last Fixes #11611.

@sankalpsthakur

Copy link
Copy Markdown
Contributor Author

Split stack: this PR is (1) patterns only. Follow-ups: #13699 genpattern, #13700 residual-entropy + Fixes #11611.

@sylvestre

Copy link
Copy Markdown
Contributor

The diff is still quite large...

Add Pattern { bytes, flip_sector } and from_code (bit 0x1000).
On write, XOR the first byte of each 512-byte sector with 0x80.
Keep the existing pass schedulers unchanged.
@sankalpsthakur
sankalpsthakur force-pushed the fix/11611-shred-distribution branch from 7a59857 to e0d91cd Compare August 1, 2026 12:41
@sankalpsthakur

Copy link
Copy Markdown
Contributor Author

Compressed the Pattern table (const helpers) so this PR stays just the model + sector-phase write. Diff should be smaller now. Scheduler still deferred to #13699/#13700.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uu shred has a different probability distribution of overwrites from GNU shred

2 participants