Performance Hasher Policy
March 1, 2026 ยท View on GitHub
VT Code uses rustc_hash selectively, not globally.
Default
Use std::collections::{HashMap, HashSet} by default.
When rustc_hash Is Allowed
Use FxHashMap / FxHashSet only for measured hotspots where keys are internal and trusted.
Good candidates:
- Internal caches and indices.
- Tool-routing lookup maps built from internal metadata.
- Short-lived per-turn maps in hot loops.
When It Is Not Allowed
Do not switch to Fx* in security-sensitive or attacker-controlled keyspaces.
Avoid for:
- Untrusted external input maps.
- Policy/security boundary logic where collision resistance matters.
Migration Gate
Before switching a map/set:
- Capture baseline with
./scripts/perf/baseline.sh baseline. - Apply selective hasher change.
- Capture latest with
./scripts/perf/baseline.sh latest. - Compare with
./scripts/perf/compare.sh. - Keep change only if there is a clear measured win and no behavioral regressions.