refactor(bootstrap): BTreeMap for overrides + simplify review #127

Merged
razvandimescu merged 1 commits from refactor/bootstrap-btreemap into main 2026-04-21 23:41:49 +08:00
razvandimescu commented 2026-04-21 23:38:01 +08:00 (Migrated from github.com)

Follow-up cleanup surfaced by the simplify pass on #126 (after merge).

Changes

  • NumaResolver.overrides: HashMapBTreeMap. HashMap iteration is randomized per-process (SipHash + random seed), which made the startup override log line order non-deterministic across restarts and required a manual .sort() on the formatted strings. BTreeMap iterates in sorted key order by type invariant — deterministic for free, one less line of code, one less allocation. Lookup cost difference (O(log N) vs O(1)) is under a nanosecond for N=2 and runs once per cold reqwest connection.
  • Rename closure binding ipsaddrs in the flat_map so it stops shadowing the outer ips: Vec<String> in the same function.
  • Trim the Suite 8 TEST-NET-1 comment — keep the "why" (zero-plain-DNS-leak invariant), drop the mechanism narration that was visible from the config itself.
  • Drop a redundant sleep 1 after waitwait already blocks on child exit. Saves 1s from the suite.

No behavior change. Zero-risk.

Validation

  • cargo test --lib — 354/354
  • cargo fmt --check — clean
  • tests/integration.sh Suite 8 — 20/20 (the override-map assertions still pass against the BTreeMap format)

Test plan

  • cargo test --lib
  • cargo fmt --check
  • SUITES=8 ./tests/integration.sh release
Follow-up cleanup surfaced by the simplify pass on #126 (after merge). ## Changes - **`NumaResolver.overrides`: `HashMap` → `BTreeMap`**. HashMap iteration is randomized per-process (SipHash + random seed), which made the startup override log line order non-deterministic across restarts and required a manual `.sort()` on the formatted strings. BTreeMap iterates in sorted key order by type invariant — deterministic for free, one less line of code, one less allocation. Lookup cost difference (O(log N) vs O(1)) is under a nanosecond for N=2 and runs once per cold reqwest connection. - **Rename closure binding** `ips` → `addrs` in the `flat_map` so it stops shadowing the outer `ips: Vec<String>` in the same function. - **Trim the Suite 8 TEST-NET-1 comment** — keep the "why" (zero-plain-DNS-leak invariant), drop the mechanism narration that was visible from the config itself. - **Drop a redundant `sleep 1` after `wait`** — `wait` already blocks on child exit. Saves 1s from the suite. No behavior change. Zero-risk. ## Validation - `cargo test --lib` — 354/354 - `cargo fmt --check` — clean - `tests/integration.sh` Suite 8 — 20/20 (the override-map assertions still pass against the BTreeMap format) ## Test plan - [x] `cargo test --lib` - [x] `cargo fmt --check` - [x] `SUITES=8 ./tests/integration.sh release`
Sign in to join this conversation.