use std::cell::Cell;
use std::sync::atomic::{AtomicU64, Ordering};
thread_local! {
static THREAD_PAGE_TREE_BUILDS: Cell<u64> = const { Cell::new(0) };
}
pub static PAGE_TREE_BUILDS: AtomicU64 = AtomicU64::new(0);
pub static MIXED_NESTED_UNITS_SCANNED: AtomicU64 = AtomicU64::new(0);
pub fn page_tree_builds() -> u64 {
PAGE_TREE_BUILDS.load(Ordering::Relaxed)
}
pub fn thread_page_tree_builds() -> u64 {
THREAD_PAGE_TREE_BUILDS.with(Cell::get)
}
pub fn mixed_nested_units_scanned() -> u64 {
MIXED_NESTED_UNITS_SCANNED.load(Ordering::Relaxed)
}
pub fn reset() {
PAGE_TREE_BUILDS.store(0, Ordering::Relaxed);
MIXED_NESTED_UNITS_SCANNED.store(0, Ordering::Relaxed);
reset_thread_page_tree_builds();
}
pub fn reset_thread_page_tree_builds() {
THREAD_PAGE_TREE_BUILDS.with(|builds| builds.set(0));
}
pub(crate) fn record_page_tree_build() {
PAGE_TREE_BUILDS.fetch_add(1, Ordering::Relaxed);
THREAD_PAGE_TREE_BUILDS.with(|builds| builds.set(builds.get().saturating_add(1)));
}