Summary
norm_case on Windows wraps GetLongPathNameW, which requires the path to exist on disk to normalize it — i.e., every call is a filesystem lookup that Defender can intercept. It is invoked from many hot paths during refresh and on inputs that repeat (the user home alone is normalized many times per refresh). Death-by-a-thousand-cuts under Defender that compounds with #453 and #454.
Note: prior audit issue #278 closed without a memoization layer being added. This issue is specifically about adding a per-process cache + auditing redundant call sites, not re-doing the audit.
Full investigation: docs/windows-perf-investigation.md (Issue 3).
Where
Hot call sites include:
Proposed fix
- Add per-process memoization for
norm_case keyed on the input path. A simple RwLock<HashMap<PathBuf, PathBuf>> would eliminate repeat syscalls. The user home, common parents, and PATH entries are normalized many times per refresh.
- Audit call sites and skip
norm_case for paths already known to be canonical (e.g., paths already produced by GetLongPathNameW, or built entirely from already-normalized components).
Estimated change size: ~50 lines for memoization.
Why this isn't covered by #278
#278 was a higher-level audit of norm_case responsibilities. It did not introduce a result cache, and the syscall density on Windows refresh paths remains a measurable cost. This issue tracks the concrete memoization + redundant-call removal.
Summary
norm_caseon Windows wrapsGetLongPathNameW, which requires the path to exist on disk to normalize it — i.e., every call is a filesystem lookup that Defender can intercept. It is invoked from many hot paths during refresh and on inputs that repeat (the user home alone is normalized many times per refresh). Death-by-a-thousand-cuts under Defender that compounds with #453 and #454.Note: prior audit issue #278 closed without a memoization layer being added. This issue is specifically about adding a per-process cache + auditing redundant call sites, not re-doing the audit.
Full investigation:
docs/windows-perf-investigation.md(Issue 3).Where
crates/pet-fs/src/path.rs—norm_case/norm_case_windows(~L102–181)Hot call sites include:
env_pathandexecutable—crates/pet-windows-registry/src/environments.rs(~L113, L150)env_path—crates/pet-windows-store/src/environments.rs(~L60)PATHentry inget_search_paths_from_env_variables—crates/pet-env-var-path/src/lib.rs(~L20)get_user_home,expand_path, and various per-environment builders.Proposed fix
norm_casekeyed on the input path. A simpleRwLock<HashMap<PathBuf, PathBuf>>would eliminate repeat syscalls. The user home, common parents, and PATH entries are normalized many times per refresh.norm_casefor paths already known to be canonical (e.g., paths already produced byGetLongPathNameW, or built entirely from already-normalized components).Estimated change size: ~50 lines for memoization.
Why this isn't covered by #278
#278 was a higher-level audit of
norm_caseresponsibilities. It did not introduce a result cache, and the syscall density on Windows refresh paths remains a measurable cost. This issue tracks the concrete memoization + redundant-call removal.