feat: add PageOps metrics to libmdbx-rs (#5786)

This commit is contained in:
Dan Cline
2023-12-15 16:43:45 +02:00
committed by GitHub
parent cc4bd7c306
commit bf37c8a076
2 changed files with 51 additions and 1 deletions

4
.gitignore vendored
View File

@ -9,7 +9,6 @@ target/
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# Generated by Intellij-based IDEs.
.idea
@ -43,5 +42,8 @@ lcov.info
# Generated by ./etc/generate-jwt.sh
jwttoken/
# Cache directory for CCLS, if using it with MDBX sources
.ccls-cache/
# Generated by CMake due to MDBX sources
crates/storage/libmdbx-rs/mdbx-sys/libmdbx/cmake-build-debug

View File

@ -411,6 +411,25 @@ impl Info {
pub fn num_readers(&self) -> usize {
self.0.mi_numreaders as usize
}
/// Return the internal page ops metrics
#[inline]
pub fn page_ops(&self) -> PageOps {
PageOps {
newly: self.0.mi_pgop_stat.newly,
cow: self.0.mi_pgop_stat.cow,
clone: self.0.mi_pgop_stat.clone,
split: self.0.mi_pgop_stat.split,
merge: self.0.mi_pgop_stat.merge,
spill: self.0.mi_pgop_stat.spill,
unspill: self.0.mi_pgop_stat.unspill,
wops: self.0.mi_pgop_stat.wops,
prefault: self.0.mi_pgop_stat.prefault,
mincore: self.0.mi_pgop_stat.mincore,
msync: self.0.mi_pgop_stat.msync,
fsync: self.0.mi_pgop_stat.fsync,
}
}
}
impl fmt::Debug for Environment {
@ -429,6 +448,35 @@ pub enum PageSize {
Set(usize),
}
/// Statistics of page operations overall of all (running, completed and aborted) transactions
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PageOps {
/// Quantity of a new pages added
pub newly: u64,
/// Quantity of pages copied for update
pub cow: u64,
/// Quantity of parent's dirty pages clones for nested transactions
pub clone: u64,
/// Page splits
pub split: u64,
/// Page merges
pub merge: u64,
/// Quantity of spilled dirty pages
pub spill: u64,
/// Quantity of unspilled/reloaded pages
pub unspill: u64,
/// Number of explicit write operations (not a pages) to a disk
pub wops: u64,
/// Number of explicit msync/flush-to-disk operations
pub msync: u64,
/// Number of explicit fsync/flush-to-disk operations
pub fsync: u64,
/// Number of prefault write operations
pub prefault: u64,
/// Number of mincore() calls
pub mincore: u64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Geometry<R> {
pub size: Option<R>,