Module pickers

Module pickers 

Source
Expand description

Predefined disambiguator closures for Snapshot::live_var_via.

Pickers are plain functions matching the closure shape live_var_via’s picker arg expects (FnOnce(&[(&str, SnapshotField)]) -> Option<usize>). Pass by name:

snap.live_var_via("nr_dispatched", pickers::max_by_counter_value)

Every picker baked into this module is a HEURISTIC for some “live instance vs prior instance” question; the picker NAME tells you what operation it performs (not what semantic the caller can conclude). Choose deliberately — the caller is responsible for picking a picker whose operation matches the metric’s shape (counter vs gauge vs sentinel) and the test’s timing relative to scheduler swaps.

Functions§

max_by_counter_value
Pick the candidate whose as_u64() value is largest. The operation is purely mechanical: project each candidate via SnapshotField::as_u64, drop those that fail to project (wrong type, missing field, etc.), and return the index of the surviving candidate with the largest u64.
max_by_sum_u64
Pick the candidate row whose fields sum to the largest u64 — the “max-activity bss” heuristic generalized to N co-picked variables. For each row, the picker as_u64-projects every field and saturating_adds them; rows containing ANY field that fails to project to u64 are dropped entirely (not partial-summed); among the surviving rows, the one with the largest sum wins.