pub fn populate_run_pooled_iterations_per_cpu_sec(stats: &mut ScenarioStats)Expand description
Inject the run-level POOLED iterations_per_cpu_sec Rate’s two Counter
components into stats.ext_metrics, summed across the cgroups that have
measured on-CPU time — the cross-cgroup re-pool axis. Rather than routing
the per-cgroup efficiency through AssertResult::merge’s worst-by-polarity
ext_metrics fold (which picks the WORST cgroup’s value, not Σ, and has
no derive post-pass), this reads the already-merged stats.cgroups vec
directly: iterations_per_cpu_sec = Σtotal_iterations /
Σ(total_cpu_time_ns/1e9) over cgroups with total_cpu_time_ns > 0 — the
per-cgroup CgroupStats::iterations_per_cpu_sec re-pooled, NOT a mean of
per-cgroup ratios, NOT the worst single cgroup.
MUST run at the eval layer AFTER the cgroup-bearing merges (every merge that
contributes a CgroupStats, so stats.cgroups holds every per-cgroup
entry) and BEFORE the sidecar write. The trailing monitor-verdict merge at
the eval layer merges an inconclusive() carrying empty stats (no cgroups,
no ext keys), so it is safe to run after this. If component injection ever
moved BEFORE a cgroup-bearing merge, that worst-by-polarity fold would
min/max these Counter keys into single-cgroup scalars, silently corrupting
the pooled sum.
A cgroup with total_cpu_time_ns == 0 (schedstat unavailable, or
num_workers == 0) is EXCLUDED from BOTH sums — mirroring the per-cgroup
CgroupStats::iterations_per_cpu_sec None-on-zero (total_cpu_time_ns > 0 implies num_workers > 0, so the one predicate covers both). Crediting
an unmeasured cgroup’s iterations against the measured cgroups’ CPU-seconds
would overstate cohort efficiency — the silent-wrong-answer this gate
prevents. Both components are inserted both-or-neither (the
derive_rate_metrics co-location invariant), only when the summed MEASURED
on-CPU time is > 0 (every cgroup unmeasured ⇒ no rate). The ns→s /1e9 is
applied ONCE here on the summed ns (not per-cgroup, to avoid repeated float
rounding), since derive_rate_metrics is a bare num/den.
total_iterations_pooled is a DISTINCT ext-only key, not the typed
total_iterations (skipped from ext_metrics; it folds cross-RUN as a MEAN
— a display average — while a Rate numerator must SUM-fold so Σnum/Σdenom
re-pools, so one shared key cannot carry both folds). Because it sums only
MEASURED cgroups, it is ≤ the merge-summed typed total_iterations (which
includes any zero-cpu-time cgroups), and equals it unless an excluded
zero-cpu-time cgroup carried iterations>0.