refactor(stats): retain exact finite timing samples
`SampleMode::Exact` retained exact samples for eight of the eleven public timing metrics. Send call, timer error, and server processing always built their `TimeMetric` with retention disabled, so a finite run reported no median for them even though they are the same public `TimeStats` type and appear in the same summary table with a Median column. Derive one `retain_exact` decision from the sample mode in `CoreStats::new` and apply it to every timing metric, so exact mode means the same thing for all of them. Running-only mode is unchanged and still retains none of them. The retention estimator counted eight exact sample streams per measurable reply. Rename it to the eleven exact samples an ordinary successful probe can retain and document the wider optional-measurement upper bound, which raises the finite estimate on this target from 668 to 764 bytes per probe. A test counts the metrics a fully measured probe actually retains and compares it against that constant, so retention and its estimate cannot drift apart unnoticed. No new median-capability type was needed: `TimeStats::median_ns` already distinguishes a retained median from an absent one, and an optional measurement the server never supplied still produces no samples at all.
This commit is contained in:
8 files changed
+491
-44
No files matched your search
@@ -35,6 +35,25 @@ fn exact_mode_scales_linearly_with_probe_count() {
|
||||
assert_eq!(config.estimated_retained_bytes(1_000), single * 1_000);
|
||||
}
|
||||
|
||||
/// Exact mode retains eleven `i128` timing streams per probe alongside its
|
||||
/// IPDV tracker state, so the timing samples alone are at least that much.
|
||||
///
|
||||
/// This checks the estimate against the storage it claims to model. It is an
|
||||
/// implementation test, not a stable public constant: the figure is free to
|
||||
/// move whenever the retention model does.
|
||||
#[test]
|
||||
fn exact_estimate_covers_every_retained_timing_sample() {
|
||||
const EXACT_TIMING_STREAMS: u64 = 11;
|
||||
let per_probe = StatsConfig::finite().estimated_retained_bytes(1);
|
||||
let timing_sample_bytes = EXACT_TIMING_STREAMS * std::mem::size_of::<i128>() as u64;
|
||||
|
||||
assert!(
|
||||
per_probe > timing_sample_bytes,
|
||||
"the estimate should cover {EXACT_TIMING_STREAMS} retained timing samples plus \
|
||||
IPDV tracker state, but a probe estimated only {per_probe} bytes"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enormous_probe_counts_saturate_instead_of_wrapping() {
|
||||
for config in [StatsConfig::finite(), StatsConfig::continuous()] {
|
||||
|
||||
Reference in new issue
Block a user