Latest Results
perf(cache): pack CachedPathImpl::meta into a CachedMeta byte (#1144)
## Summary
`CachedPathImpl::meta` was a `OnceLock<Option<(bool, bool)>>` (16 bytes) recording whether the path is a file and/or directory. Filesystem metadata is idempotent β `OnceLock`'s exactly-once initialization is a nicety, not a correctness requirement: if two threads race they both re-`stat` and both store the same answer.
This PR introduces a `CachedMeta` struct in `src/cache/cached_meta.rs` that wraps an `AtomicU8`, encapsulates the encoding of the six possible states (uninitialized / `None` / the four `(is_file, is_dir)` combinations), and exposes a single `get_or_init` accessor.
`CachedPathImpl::meta` becomes:
```rust
pub meta: CachedMeta,
```
β¦and the accessor on `CachedPath` collapses to a one-liner:
```rust
fn metadata<Fs: FileSystem>(&self, fs: &Fs) -> Option<(bool, bool)> {
self.meta.get_or_init(|| fs.metadata(&self.path).ok().map(|r| (r.is_file, r.is_dir)))
}
```
All encoding/decoding/`AtomicU8` plumbing is private to the new module.
## Size impact
The field shrinks from 16 bytes to 1, saving **15 bytes per cached path entry**. For sessions with 10k cached paths that's ~150 KB; with 100k it's ~1.5 MB.
π€ Generated with [Claude Code](https://claude.com/claude-code) perf(cache): pack CachedPathImpl::meta into a CachedMeta byte (#1144)
## Summary
`CachedPathImpl::meta` was a `OnceLock<Option<(bool, bool)>>` (16 bytes) recording whether the path is a file and/or directory. Filesystem metadata is idempotent β `OnceLock`'s exactly-once initialization is a nicety, not a correctness requirement: if two threads race they both re-`stat` and both store the same answer.
This PR introduces a `CachedMeta` struct in `src/cache/cached_meta.rs` that wraps an `AtomicU8`, encapsulates the encoding of the six possible states (uninitialized / `None` / the four `(is_file, is_dir)` combinations), and exposes a single `get_or_init` accessor.
`CachedPathImpl::meta` becomes:
```rust
pub meta: CachedMeta,
```
β¦and the accessor on `CachedPath` collapses to a one-liner:
```rust
fn metadata<Fs: FileSystem>(&self, fs: &Fs) -> Option<(bool, bool)> {
self.meta.get_or_init(|| fs.metadata(&self.path).ok().map(|r| (r.is_file, r.is_dir)))
}
```
All encoding/decoding/`AtomicU8` plumbing is private to the new module.
## Size impact
The field shrinks from 16 bytes to 1, saving **15 bytes per cached path entry**. For sessions with 10k cached paths that's ~150 KB; with 100k it's ~1.5 MB.
π€ Generated with [Claude Code](https://claude.com/claude-code)perf/cached-path-meta-atomic Latest Branches
0%
release-plz-2026-03-02T05-19-13Z -4%
perf/cached-path-meta-atomic -3%
perf/specifier-unescape-lockstep Β© 2026 CodSpeed Technology