Skip to content

Navi’s router is engineered for allocation-free hot paths. This page explains where the guarantees come from and what they bought, with the numbers from the repository’s own benchmarks (docs/BENCHMARKS.md, criterion medians, 130-route tree).

Guarantee Where you see it
Zero-copy route matching Stack-collected parameter bindings, interned Arc<str> segment names, FxHash static-child lookup, HashMap materialized once on success. Matching is 14–38% faster across the board.
Per-frame paths allocate nothing use_params!, use_search!, and use_loader_data! read navigation-time caches; Link active checks are branch-and-byte comparisons (−94%); loader QueryKeys are memoized per navigation.
Bounded memory everywhere Ring-buffered event log, capped preload registry, O(1) scroll-eviction, Arc<RouteTree> shared between core and adapter (no deep tree clone at startup).
Lock-free single-owner history No Mutex in the navigation path; back/forward is −67%.

Matching (per navigation, 130-route tree):

Benchmark Before After Δ
match_path/static 64.8 ns 41.8 ns −35%
match_path/dynamic 163.2 ns 131.0 ns −19%
match_path/static_beats_dynamic 60.7 ns 46.5 ns −23%
match_path/deep_nested 242.1 ns 151.3 ns −38%
match_path/splat 204.6 ns 139.4 ns −32%

Navigation and history (per navigation):

Benchmark Before After Δ
navigate/replace_static 128.1 ns 108.6 ns −15%
navigate/replace_dynamic 292.1 ns 190.1 ns −35%
history/back_forward 212.8 ns 70.3 ns −67%
transact/two_replaces 499.2 ns 373.1 ns −25%

Location parsing (per navigation):

Benchmark Before After Δ
location_new/query 323.4 ns 302.4 ns −7%
location_new/query_hash 446.0 ns 325.2 ns −27%
location_new/coerce (7 values) 760.5 ns 632.7 ns −17%

You can reproduce the numbers with the commands documented in docs/BENCHMARKS.md (cargo bench --bench core --bench adapter against the saved baselines).

The workspace enforces the same discipline in CI:

  • cargo clippy --workspace --all-targets -- -W clippy::pedantic -D warnings — zero warnings, with no #[allow] attributes in the codebase (suppressions use targeted #[expect], which errors when stale).
  • The four validation integrations (validator, garde, validify, valico) are mutually exclusive blanket impls, so they are linted and tested per feature instead of under --all-features.
  • clippy.toml calibrates a few shape thresholds for the devtools UI module’s large render methods instead of scattering allow attributes.
  • Criterion benchmarks (benches/core.rs for the engine, benches/adapter.rs for the runtime) guard the hot paths against regressions.

The rendering stack is quoin and the data stack is rs-query — both chosen so the router itself never blocks on a framework or an ambient async runtime.