Skip to main content

Module PathCanon

Module PathCanon 

Source
Expand description

Process-wide canonical-path cache.

Keyed by lexical input path; value is the result of dunce::canonicalize. Hits skip the syscall; misses run it and cache the result.

The fs-scope security gate (Environment::Utility::PathSecurity) canonicalises every incoming path on every call. The same paths recur thousands of times during boot - 113 extension manifest paths, ~80 chunked workbench JS imports, ~60 git-extension scope checks, every vscode-file:// request - so collapsing repeats to a hash lookup saves ~150 ms cumulative on the boot path.

TTL = 60 s to bound staleness against external mv/rename. moka’s time_to_idle resets on each access, so hot paths stay cached indefinitely while one-shot paths evict naturally.

Modules§

Cache 🔒
Process-global canonical-path cache backing store.
CacheStats
Diagnostic snapshot of the canonical-path cache.
Canonicalize
Canonicalise via the cache. Returns the cached entry on hit; runs dunce::canonicalize on miss and caches the result.
CanonicalizeUncached
Canonicalise without caching. For one-shot calls where the result is immediately discarded - avoids polluting the cache with paths that won’t be repeated.
Clear
Clear the entire path-canon cache. Diagnostic / shutdown use.
Invalidate
Force-evict an entry. Called from notify watchers when a path rename is observed inside the workspace, or by the dev-mode hot-reload signal.
SpawnDiagnosticLogger
Spawn a tokio task that logs cache stats every 30 s under the path-canon trace tag. Optional; call from RunTime::Setup when the user has Trace=path-canon enabled.
Stats
Capture a diagnostic snapshot of the cache.