1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Per-size-class allocation telemetry.
//!
//! Tracks process-wide allocation and deallocation counts per size class using
//! relaxed atomic counters. The allocation-byte total is derived from the
//! immutable class stride. Per-thread counters batch global updates so the
//! allocator hot path does not contend on one cache line for every operation.
//!
//! The counters are always enabled (no feature gate). They are not
//! synchronised with each other — a snapshot can observe counts from
//! different points in time — and pending per-thread batches may not yet be
//! visible. Each global counter is monotone-non-decreasing, so the
//! live-allocation estimate `alloc_count - dealloc_count` is an under-estimate
//! until the owning thread flushes its pending batch rather than a negative
//! artefact.
//!
//! ## Reset boundary (generation counter)
//!
//! `reset_bin_stats()` increments a process-wide `RESET_GENERATION` counter.
//! Each TLS batch records the generation it was started in. When a batch flush
//! sees that the global generation has advanced past its recorded generation,
//! it silently discards the batch instead of adding stale observations to the
//! fresh counters. This ensures that every worker's pre-reset activity is
//! excluded from post-reset snapshots regardless of flush ordering.
//!
//! Fragmentation ratio per class: `(alloc_bytes - dealloc_bytes) /
//! alloc_bytes`. Internal fragmentation per class: `(alloc_bytes -
//! requested_bytes) / alloc_bytes`.
//!
//! The public reading API and its tests live in the private `api` module;
//! this file stays a manifest of the module tree and its curated re-exports.
pub use ;
pub use ;
pub use BinSnapshot;