| 1 |
#[cfg(tokio_internal_mt_counters)] |
| 2 |
mod imp { |
| 3 |
use std::sync::atomic::AtomicUsize; |
| 4 |
use std::sync::atomic::Ordering::Relaxed; |
| 5 |
|
| 6 |
static NUM_MAINTENANCE: AtomicUsize = AtomicUsize::new(0); |
| 7 |
static NUM_NOTIFY_LOCAL: AtomicUsize = AtomicUsize::new(0); |
| 8 |
static NUM_NOTIFY_REMOTE: AtomicUsize = AtomicUsize::new(0); |
| 9 |
static NUM_UNPARKS_LOCAL: AtomicUsize = AtomicUsize::new(0); |
| 10 |
static NUM_UNPARKS_REMOTE: AtomicUsize = AtomicUsize::new(0); |
| 11 |
static NUM_LIFO_SCHEDULES: AtomicUsize = AtomicUsize::new(0); |
| 12 |
static NUM_LIFO_CAPPED: AtomicUsize = AtomicUsize::new(0); |
| 13 |
static NUM_STEALS: AtomicUsize = AtomicUsize::new(0); |
| 14 |
static NUM_OVERFLOW: AtomicUsize = AtomicUsize::new(0); |
| 15 |
static NUM_PARK: AtomicUsize = AtomicUsize::new(0); |
| 16 |
static NUM_POLLS: AtomicUsize = AtomicUsize::new(0); |
| 17 |
static NUM_LIFO_POLLS: AtomicUsize = AtomicUsize::new(0); |
| 18 |
static NUM_REMOTE_BATCH: AtomicUsize = AtomicUsize::new(0); |
| 19 |
static NUM_GLOBAL_QUEUE_INTERVAL: AtomicUsize = AtomicUsize::new(0); |
| 20 |
static NUM_NO_AVAIL_CORE: AtomicUsize = AtomicUsize::new(0); |
| 21 |
static NUM_RELAY_SEARCH: AtomicUsize = AtomicUsize::new(0); |
| 22 |
static NUM_SPIN_STALL: AtomicUsize = AtomicUsize::new(0); |
| 23 |
static NUM_NO_LOCAL_WORK: AtomicUsize = AtomicUsize::new(0); |
| 24 |
|
| 25 |
impl Drop for super::Counters { |
| 26 |
fn drop(&mut self) { |
| 27 |
let notifies_local = NUM_NOTIFY_LOCAL.load(Relaxed); |
| 28 |
let notifies_remote = NUM_NOTIFY_REMOTE.load(Relaxed); |
| 29 |
let unparks_local = NUM_UNPARKS_LOCAL.load(Relaxed); |
| 30 |
let unparks_remote = NUM_UNPARKS_REMOTE.load(Relaxed); |
| 31 |
let maintenance = NUM_MAINTENANCE.load(Relaxed); |
| 32 |
let lifo_scheds = NUM_LIFO_SCHEDULES.load(Relaxed); |
| 33 |
let lifo_capped = NUM_LIFO_CAPPED.load(Relaxed); |
| 34 |
let num_steals = NUM_STEALS.load(Relaxed); |
| 35 |
let num_overflow = NUM_OVERFLOW.load(Relaxed); |
| 36 |
let num_park = NUM_PARK.load(Relaxed); |
| 37 |
let num_polls = NUM_POLLS.load(Relaxed); |
| 38 |
let num_lifo_polls = NUM_LIFO_POLLS.load(Relaxed); |
| 39 |
let num_remote_batch = NUM_REMOTE_BATCH.load(Relaxed); |
| 40 |
let num_global_queue_interval = NUM_GLOBAL_QUEUE_INTERVAL.load(Relaxed); |
| 41 |
let num_no_avail_core = NUM_NO_AVAIL_CORE.load(Relaxed); |
| 42 |
let num_relay_search = NUM_RELAY_SEARCH.load(Relaxed); |
| 43 |
let num_spin_stall = NUM_SPIN_STALL.load(Relaxed); |
| 44 |
let num_no_local_work = NUM_NO_LOCAL_WORK.load(Relaxed); |
| 45 |
|
| 46 |
println!("---"); |
| 47 |
println!("notifies (remote): {}", notifies_remote); |
| 48 |
println!(" notifies (local): {}", notifies_local); |
| 49 |
println!(" unparks (local): {}", unparks_local); |
| 50 |
println!(" unparks (remote): {}", unparks_remote); |
| 51 |
println!(" notify, no core: {}", num_no_avail_core); |
| 52 |
println!(" maintenance: {}", maintenance); |
| 53 |
println!(" LIFO schedules: {}", lifo_scheds); |
| 54 |
println!(" LIFO capped: {}", lifo_capped); |
| 55 |
println!(" steals: {}", num_steals); |
| 56 |
println!(" queue overflows: {}", num_overflow); |
| 57 |
println!(" parks: {}", num_park); |
| 58 |
println!(" polls: {}", num_polls); |
| 59 |
println!(" polls (LIFO): {}", num_lifo_polls); |
| 60 |
println!("remote task batch: {}", num_remote_batch); |
| 61 |
println!("global Q interval: {}", num_global_queue_interval); |
| 62 |
println!(" relay search: {}", num_relay_search); |
| 63 |
println!(" spin stall: {}", num_spin_stall); |
| 64 |
println!(" no local work: {}", num_no_local_work); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
pub(crate) fn inc_num_inc_notify_local() { |
| 69 |
NUM_NOTIFY_LOCAL.fetch_add(1, Relaxed); |
| 70 |
} |
| 71 |
|
| 72 |
pub(crate) fn inc_num_notify_remote() { |
| 73 |
NUM_NOTIFY_REMOTE.fetch_add(1, Relaxed); |
| 74 |
} |
| 75 |
|
| 76 |
pub(crate) fn inc_num_unparks_local() { |
| 77 |
NUM_UNPARKS_LOCAL.fetch_add(1, Relaxed); |
| 78 |
} |
| 79 |
|
| 80 |
pub(crate) fn inc_num_unparks_remote() { |
| 81 |
NUM_UNPARKS_REMOTE.fetch_add(1, Relaxed); |
| 82 |
} |
| 83 |
|
| 84 |
pub(crate) fn inc_num_maintenance() { |
| 85 |
NUM_MAINTENANCE.fetch_add(1, Relaxed); |
| 86 |
} |
| 87 |
|
| 88 |
pub(crate) fn inc_lifo_schedules() { |
| 89 |
NUM_LIFO_SCHEDULES.fetch_add(1, Relaxed); |
| 90 |
} |
| 91 |
|
| 92 |
pub(crate) fn inc_lifo_capped() { |
| 93 |
NUM_LIFO_CAPPED.fetch_add(1, Relaxed); |
| 94 |
} |
| 95 |
|
| 96 |
pub(crate) fn inc_num_steals() { |
| 97 |
NUM_STEALS.fetch_add(1, Relaxed); |
| 98 |
} |
| 99 |
|
| 100 |
pub(crate) fn inc_num_overflows() { |
| 101 |
NUM_OVERFLOW.fetch_add(1, Relaxed); |
| 102 |
} |
| 103 |
|
| 104 |
pub(crate) fn inc_num_parks() { |
| 105 |
NUM_PARK.fetch_add(1, Relaxed); |
| 106 |
} |
| 107 |
|
| 108 |
pub(crate) fn inc_num_polls() { |
| 109 |
NUM_POLLS.fetch_add(1, Relaxed); |
| 110 |
} |
| 111 |
|
| 112 |
pub(crate) fn inc_num_lifo_polls() { |
| 113 |
NUM_LIFO_POLLS.fetch_add(1, Relaxed); |
| 114 |
} |
| 115 |
|
| 116 |
pub(crate) fn inc_num_remote_batch() { |
| 117 |
NUM_REMOTE_BATCH.fetch_add(1, Relaxed); |
| 118 |
} |
| 119 |
|
| 120 |
pub(crate) fn inc_global_queue_interval() { |
| 121 |
NUM_GLOBAL_QUEUE_INTERVAL.fetch_add(1, Relaxed); |
| 122 |
} |
| 123 |
|
| 124 |
pub(crate) fn inc_notify_no_core() { |
| 125 |
NUM_NO_AVAIL_CORE.fetch_add(1, Relaxed); |
| 126 |
} |
| 127 |
|
| 128 |
pub(crate) fn inc_num_relay_search() { |
| 129 |
NUM_RELAY_SEARCH.fetch_add(1, Relaxed); |
| 130 |
} |
| 131 |
|
| 132 |
pub(crate) fn inc_num_spin_stall() { |
| 133 |
NUM_SPIN_STALL.fetch_add(1, Relaxed); |
| 134 |
} |
| 135 |
|
| 136 |
pub(crate) fn inc_num_no_local_work() { |
| 137 |
NUM_NO_LOCAL_WORK.fetch_add(1, Relaxed); |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
#[cfg(not(tokio_internal_mt_counters))] |
| 142 |
mod imp { |
| 143 |
pub(crate) fn inc_num_inc_notify_local() {} |
| 144 |
pub(crate) fn inc_num_notify_remote() {} |
| 145 |
pub(crate) fn inc_num_unparks_local() {} |
| 146 |
pub(crate) fn inc_num_unparks_remote() {} |
| 147 |
pub(crate) fn inc_num_maintenance() {} |
| 148 |
pub(crate) fn inc_lifo_schedules() {} |
| 149 |
pub(crate) fn inc_lifo_capped() {} |
| 150 |
pub(crate) fn inc_num_steals() {} |
| 151 |
pub(crate) fn inc_num_overflows() {} |
| 152 |
pub(crate) fn inc_num_parks() {} |
| 153 |
pub(crate) fn inc_num_polls() {} |
| 154 |
pub(crate) fn inc_num_lifo_polls() {} |
| 155 |
pub(crate) fn inc_num_remote_batch() {} |
| 156 |
pub(crate) fn inc_global_queue_interval() {} |
| 157 |
pub(crate) fn inc_notify_no_core() {} |
| 158 |
pub(crate) fn inc_num_relay_search() {} |
| 159 |
pub(crate) fn inc_num_spin_stall() {} |
| 160 |
pub(crate) fn inc_num_no_local_work() {} |
| 161 |
} |
| 162 |
|
| 163 |
#[derive(Debug)] |
| 164 |
pub(crate) struct Counters; |
| 165 |
|
| 166 |
pub(super) use imp::*; |