Initial
This commit is contained in:
1 parent
2cff35f215
commit
1b0d534e6c
358 files changed
+253978
-74
No files matched your search
@@ -0,0 +1,76 @@
|
||||
|
||||
|
||||
use std::sync::atomic::{AtomicU64, Ordering::Relaxed};
|
||||
|
||||
pub(crate) fn on() -> bool {
|
||||
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*ON.get_or_init(|| crate::switch::on("EONACAT_XS_HEAP_SYNC_AT_SUBMIT"))
|
||||
}
|
||||
|
||||
pub(crate) fn round_after(asked: u64, done: u64) -> (u64, bool) {
|
||||
if asked >= done + 2 { (asked, false) } else { (asked + 1, true) }
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
|
||||
static MARK: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
pub(crate) fn set_mark(mark: u64) {
|
||||
MARK.set(mark);
|
||||
}
|
||||
|
||||
static PREP_FLOOR: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
pub(crate) fn prep_wrote() {
|
||||
PREP_FLOOR.fetch_max(crate::descriptor::round_mark(), Relaxed);
|
||||
STATS[PREP_WRITES].fetch_add(1, Relaxed);
|
||||
}
|
||||
|
||||
pub(crate) fn needed() -> u64 {
|
||||
if !on() {
|
||||
return 0;
|
||||
}
|
||||
match MARK.get() {
|
||||
0 => {
|
||||
STATS[NO_MARK].fetch_add(1, Relaxed);
|
||||
0
|
||||
}
|
||||
m => m.max(PREP_FLOOR.load(Relaxed)),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) static STATS: [AtomicU64; 7] = [const { AtomicU64::new(0) }; 7];
|
||||
pub(crate) const ROUNDS_ASKED: usize = 0;
|
||||
pub(crate) const EARLY_ROUNDS: usize = 1;
|
||||
const PREP_WRITES: usize = 2;
|
||||
const HEAPS_NS: usize = 3;
|
||||
const HEAPS: usize = 4;
|
||||
const NO_MARK: usize = 5;
|
||||
pub(crate) const LATE_ROUNDS: usize = 6;
|
||||
|
||||
pub(crate) fn heaps_waited(ns: u64) {
|
||||
STATS[HEAPS_NS].fetch_add(ns, Relaxed);
|
||||
STATS[HEAPS].fetch_add(1, Relaxed);
|
||||
}
|
||||
|
||||
pub(crate) fn line(frames: f64) {
|
||||
let s: [f64; 7] = std::array::from_fn(|i| STATS[i].swap(0, Relaxed) as f64);
|
||||
if !on() {
|
||||
return;
|
||||
}
|
||||
let f = frames.max(1.0);
|
||||
tracing::info!(
|
||||
"the heaps' records asked for at the title's submit, per frame (EONACAT_XS_HEAP_SYNC_AT_SUBMIT=1): the submitting thread \
|
||||
waited {:.2} ms in {:.1} preparings; {:.1} rounds asked for at a submit, {:.1} preparings found theirs asked earlier, \
|
||||
{:.1} asked it at the preparing, {:.1} had no mark; {:.1} preparings wrote a heap's memory",
|
||||
s[HEAPS_NS] / 1e6 / f,
|
||||
s[HEAPS] / f,
|
||||
s[ROUNDS_ASKED] / f,
|
||||
s[EARLY_ROUNDS] / f,
|
||||
s[LATE_ROUNDS] / f,
|
||||
s[NO_MARK] / f,
|
||||
s[PREP_WRITES] / f,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user