You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/METRICS.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ The <b>metrics</b> feature provides production-grade latency metrics with near-z
50
50
### Manual installation:
51
51
```toml
52
52
[dependencies]
53
-
benchmark = { version = "0.5.8", features = ["metrics"] }
53
+
benchmark = { version = "0.7.1", features = ["metrics"] }
54
54
```
55
55
> ⚙️ Add directly to your `Cargo.toml`.
56
56
@@ -87,6 +87,20 @@ fn main() {
87
87
}
88
88
```
89
89
90
+
<br>
91
+
<hr>
92
+
<br>
93
+
94
+
## Accuracy and Performance Trade-offs
95
+
96
+
-**Bounds selection**: Choose `lowest` and `highest` close to your SLOs. Tighter ranges improve percentile precision and reduce memory.
97
+
-**Input clamping**: `Watch::record()` clamps to histogram bounds. Percentile queries clamp `q` to [0.0, 1.0]. This avoids panics and yields sane results for out-of-range inputs.
98
+
-**Precision vs memory**: The built-in histogram is fixed-size and optimized for lock-free recording; memory usage grows with the configured range. Tune bounds rather than sampling frequency.
99
+
-**Contention**: Recording is lock-free; map access for new metric names may take a write lock once. Keep metric names stable and low-cardinality. Consider sharding hot metrics and merging snapshots offline if necessary.
100
+
-**Snapshots**: Percentiles are computed from cloned histograms outside locks to minimize contention. Snapshot costs scale with the number of metrics.
101
+
-**Zero durations**: Some platforms can return 0ns for extremely fast ops; this is preserved. Clamp in presentation if needed, not at collection.
102
+
-**Tracing hooks (optional)**: Enabling the `trace` feature adds lightweight, gated logging for hot-path events to aid debugging overhead; it is zero-cost when disabled.
0 commit comments