perf(pools): make measurement statistics allocation free (#3412)
* perf(pools): make measurement statistics allocation free
Compute the average directly from the circular buffer and the median via
a guarded quickselect over a shared snapshot instead of
`toArray()`+`slice().sort()`:
- average: O(H) single pass over the buffer (`CircularBuffer.sum()`), no allocation
- median: O(H) quickselect over a shared snapshot (native-sort depth
fallback keeps the worst case at O(H log H)), no allocation
Results are bit-for-bit identical to `average(history.toArray())` and
`median(history.toArray())`, fuzz-tested against reference
implementations with `Object.is`.
Measured: median path x7.2, average path x1.56 per task completion;
+10 % throughput on a 2-core fair-share pool.
* [autofix.ci] apply automated fixes
* test(pools): make statistics fuzz falsifiable and cover sum() directly
Feed the bit-for-bit fuzz with wide-dynamics values (1e-8 to 1e8) so
that the float64 summation order becomes observable: a mutation
reversing the accumulation order of `sum()` now fails the test (checked
by mutation). Add a direct `sum()` unit test (empty, full, wrap,
partial drain).
* fix(pools): preserve negative zero in single-value measurement average
`sum()` folds `- 0` into `+ 0` (`0 + (- 0)`), while the replaced
`average()` returned `dataSet[0]` as is. Read the single element from
the snapshot instead, and pin the behavior with an `Object.is` test.
Also document the remaining known difference of the quickselect median
(occurrence sign among equal-comparing `- 0`/`NaN` values, unreachable
from measurement producers).
* [autofix.ci] apply automated fixes
* refactor(pools): name the rank-selection tuning constants
Extract the insertion-sort cutoff and the quickselect depth factor of
`selectAtRank()` into documented module constants, following the
existing private-constant convention. No behavior change.