Skip to content

find: look up each owner and group name once - #1033

Merged
sylvestre merged 2 commits into
uutils:mainfrom
KrushnXGIT:find-cache-owner-names
Nov 21, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
KrushnXGIT:find-cache-owner-names

Conversation

@KrushnXGIT

Copy link
Copy Markdown
Contributor

find -ls looks up the owner and group name of every file it prints, and each lookup reads /etc/passwd and /etc/group again. On /usr/share (33,907 entries) that is 71,025 openat calls, against 3,250 for GNU find. -printf %u and %g do the same.

A tree usually has only a few owners, so this keeps each name after its first lookup:

  • names.rs holds a uid → name and a gid → name map, used by -ls and -printf %u/%g.
  • An id with no passwd/group entry still shows as the number, as before.

hyperfine, 20 runs, Ubuntu 24.04:

find /usr/share ... GNU 4.9 main this PR
-ls 104.5 ± 1.9 ms 263.2 ± 3.4 ms 98.0 ± 0.7 ms
-printf '%u:%g\n' 212.0 ± 1.3 ms 229.7 ± 1.6 ms 70.6 ± 0.3 ms

Output and exit code are the same as main for -ls and -printf %u:%g:%U:%G on /usr/share and on a tree owned by root, ubuntu, nobody and an unmapped uid/gid (54321). cargo test, clippy and fmt pass.

Part of #430 (the user/group name cache).

@codspeed

codspeed Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 15 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 20 untouched benchmarks


Comparing KrushnXGIT:find-cache-owner-names (54184d8) with main (f4383e8)

Open in CodSpeed

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (a86eee2) to head (54184d8).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1033      +/-   ##
==========================================
+ Coverage   92.26%   92.29%   +0.03%     
==========================================
  Files          37       38       +1     
  Lines        8678     8714      +36     
  Branches      429      429              
==========================================
+ Hits         8007     8043      +36     
  Misses        532      532              
  Partials      139      139              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/find/matchers/names.rs Resolved
Comment thread src/find/matchers/names.rs Resolved
@sylvestre
sylvestre merged commit 2fd3dec into uutils:main Nov 21, 2026
35 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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