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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::loom::sync::atomic::Ordering::Relaxed;
use crate::loom::sync::atomic::{AtomicU64, AtomicUsize};
#[derive(Debug)]
#[repr(align(128))]
pub(crate) struct WorkerMetrics {
pub(crate) park_count: AtomicU64,
pub(crate) noop_count: AtomicU64,
pub(crate) steal_count: AtomicU64,
pub(crate) steal_operations: AtomicU64,
pub(crate) poll_count: AtomicU64,
pub(crate) busy_duration_total: AtomicU64,
pub(crate) local_schedule_count: AtomicU64,
pub(crate) overflow_count: AtomicU64,
pub(crate) queue_depth: AtomicUsize,
}
impl WorkerMetrics {
pub(crate) fn new() -> WorkerMetrics {
WorkerMetrics {
park_count: AtomicU64::new(0),
noop_count: AtomicU64::new(0),
steal_count: AtomicU64::new(0),
steal_operations: AtomicU64::new(0),
poll_count: AtomicU64::new(0),
overflow_count: AtomicU64::new(0),
busy_duration_total: AtomicU64::new(0),
local_schedule_count: AtomicU64::new(0),
queue_depth: AtomicUsize::new(0),
}
}
pub(crate) fn queue_depth(&self) -> usize {
self.queue_depth.load(Relaxed)
}
pub(crate) fn set_queue_depth(&self, len: usize) {
self.queue_depth.store(len, Relaxed);
}
}