Skip to content

updatedb: improve perf and error message - #713

Merged
sylvestre merged 2 commits into
uutils:mainfrom
sylvestre:fstype-reuse-cached-metadata
Jun 8, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
sylvestre:fstype-reuse-cached-metadata

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

No description provided.

@codspeed

codspeed Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing sylvestre:fstype-reuse-cached-metadata (7918945) with main (5d0e7ad)

Open in CodSpeed

@codecov

codecov Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.79070% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.83%. Comparing base (5d0e7ad) to head (7918945).

Files with missing lines Patch % Lines
src/updatedb/mod.rs 71.87% 9 Missing ⚠️
src/find/matchers/fs.rs 36.36% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #713      +/-   ##
==========================================
- Coverage   92.01%   91.83%   -0.18%     
==========================================
  Files          35       35              
  Lines        7097     7129      +32     
  Branches      374      375       +1     
==========================================
+ Hits         6530     6547      +17     
- Misses        423      437      +14     
- Partials      144      145       +1     

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

The -fstype matcher called path.symlink_metadata() (a statx/lstat syscall)
on every entry before consulting its cache, just to obtain the device id.
With several -fstype clauses on the same expression (as updatedb builds:
nfs/NFS/proc), every file was stat'd once per clause.

Derive the device id from WalkEntry::metadata() instead, which is cached on
the entry in a OnceCell and shared across all matchers, so each file is
stat'd at most once regardless of how many -fstype clauses run.

On 'updatedb --localpaths=/usr' (~506k files) this drops statx calls from
~1.52M to ~506k and wall-clock from ~1.82s to ~1.32s, with byte-identical
output.
@sylvestre
sylvestre force-pushed the fstype-reuse-cached-metadata branch from 29c8fd1 to 55fae46 Compare June 8, 2026 21:19
Opening the output file with `?` surfaced a bare "No such file or
directory" with no indication of which file failed (easy to hit because the
default output path /usr/local/var/locatedb often doesn't exist).

Report it like GNU does, naming the path and the reason, e.g.
`cannot create '/usr/local/var/locatedb': No such file or directory`.
strip_errno() drops the trailing "(os error N)" noise.
@sylvestre
sylvestre force-pushed the fstype-reuse-cached-metadata branch from 55fae46 to 7918945 Compare June 8, 2026 21:28
@sylvestre
sylvestre marked this pull request as ready for review June 8, 2026 21:32
@sylvestre
sylvestre merged commit 62deaf6 into uutils:main Jun 8, 2026
20 of 22 checks passed
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.

1 participant