mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-06 04:29:52 +00:00
docs(stats): fix misleading/stale comments and rename test_counter
- GC test: cutoff is in the future, so every metric is stale by timestamp (not "nothing is stale"); only live handles retain. - GC loop: drop the inaccurate "no Instant alloc" rationale. - bench: the handle path no longer calls Instant::now() (it uses fastant); reword the HANDLE_TOTAL_WORK rationale. - rename test_unsafe_counter -> test_counter to match the type rename.
This commit is contained in:
@@ -31,8 +31,9 @@ use parking_lot::Mutex;
|
||||
|
||||
const COUNTER_SHARDS: usize = 16;
|
||||
const TOTAL_WORK: u64 = 8_000_000;
|
||||
// The handle path calls `Instant::now()` per `add`, so it is far heavier per op
|
||||
// than the counter-only groups; use a smaller total to keep the bench fast.
|
||||
// The handle path does a counter update plus a timestamp `touch` per `add`,
|
||||
// so it is heavier per op than the counter-only groups; use a smaller total to
|
||||
// keep the bench fast.
|
||||
const HANDLE_TOTAL_WORK: u64 = 2_000_000;
|
||||
const TASK_COUNTS: &[usize] = &[1, 2, 4, 8, 16, 32];
|
||||
|
||||
|
||||
@@ -578,7 +578,8 @@ impl StatsManager {
|
||||
interval.tick().await;
|
||||
|
||||
// Drop metrics untouched for 180s and with no live handles.
|
||||
// Compare in the millis-since-base domain; no Instant alloc.
|
||||
// Compare in the millis-since-base domain so neither the hot
|
||||
// path nor GC reconstructs an `Instant` or locks.
|
||||
let cutoff_millis = now_millis().saturating_sub(180_000);
|
||||
|
||||
let Some(counters) = counters_clone.upgrade() else {
|
||||
@@ -756,7 +757,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_unsafe_counter() {
|
||||
async fn test_counter() {
|
||||
let counter = Counter::new();
|
||||
|
||||
assert_eq!(counter.get(), 0);
|
||||
@@ -908,8 +909,8 @@ mod tests {
|
||||
let counter = stats.get_simple_counter(MetricName::TrafficBytesForwarded);
|
||||
counter.set(1);
|
||||
|
||||
// Cutoff 1s in the future, so nothing is stale by timestamp; only live
|
||||
// handles keep a metric.
|
||||
// Cutoff 1s in the future, so every metric is stale by timestamp; only
|
||||
// a live handle keeps a metric.
|
||||
let cutoff_millis = now_millis() + 1_000;
|
||||
stats
|
||||
.counters
|
||||
|
||||
Reference in New Issue
Block a user