Skip to content

refactor: avoid unnecessary HashSet::contains - #14985

Merged
cakebaker merged 3 commits into
uutils:mainfrom
xtqqczze:refactor-du-hashset-contains
Oct 1, 2026
Merged

cakebaker merged 3 commits into
uutils:mainfrom
xtqqczze:refactor-du-hashset-contains

Conversation

@xtqqczze

@xtqqczze xtqqczze commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Replace the contains + insert pair with a single HashSet::insert call.

This reduces two hash table lookups to one while preserving existing behavior.

@xtqqczze
xtqqczze force-pushed the refactor-du-hashset-contains branch from a34ed3f to 6718535 Compare September 30, 2026 16:40
@codspeed

codspeed Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.58%

❌ 1 regressed benchmark
✅ 24 untouched benchmarks
⏩ 422 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation du_all_wide_tree[(5000, 500)] 37.1 ms 38.5 ms -3.58%

Tip

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


Comparing xtqqczze:refactor-du-hashset-contains (cf8fd9a) with main (cacdd8d)

Open in CodSpeed

Footnotes

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

@xtqqczze

Copy link
Copy Markdown
Collaborator Author

@samueltardieu I'm surprised Clippy doesn't suggest replacing a contains + insert pair with HashSet::insert.

@xtqqczze

xtqqczze commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Benchmark variance tracked by #14984.

@xtqqczze
xtqqczze marked this pull request as ready for review September 30, 2026 19:40
Replace the `contains` + `insert` pair used for inode tracking with a
single `HashSet::insert` call.

This reduces two hash table lookups to one while preserving existing
behavior.
@xtqqczze
xtqqczze force-pushed the refactor-du-hashset-contains branch from 6718535 to cf8fd9a Compare September 30, 2026 20:50
@xtqqczze xtqqczze changed the title perf(du): optimize inode deduplication refactor: avoid unnecessary HashSet::contains Sep 30, 2026
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/id/setgid. tests/id/setgid is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)

@cakebaker
cakebaker merged commit 00399e5 into uutils:main Oct 1, 2026
104 of 107 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

@xtqqczze
xtqqczze deleted the refactor-du-hashset-contains branch October 1, 2026 07:56
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.

2 participants