Skip to content

Commit

Permalink
feat: add PageOps metrics to libmdbx-rs (#5786)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Dec 15, 2023
1 parent cc4bd7c commit bf37c8a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ target/
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb


# Generated by Intellij-based IDEs.
.idea

Expand Down Expand Up @@ -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
48 changes: 48 additions & 0 deletions crates/storage/libmdbx-rs/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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>,
Expand Down

0 comments on commit bf37c8a

Please sign in to comment.