summaryrefslogtreecommitdiffstats
path: root/src/swarm/stats.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-25 13:07:48 +0100
committertv <tv@krebsco.de>2026-10-25 13:07:48 +0100
commit3af7c116d41c06822006fb447211e3792862fd7c (patch)
tree52b9cdc0630fbd7b811e6b6e20a1f61624806ee8 /src/swarm/stats.rs
parentd6620dc266b593e9ed269bcb7e65d3d8c9710d27 (diff)
add disk I/O stats
Diffstat (limited to 'src/swarm/stats.rs')
-rw-r--r--src/swarm/stats.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/swarm/stats.rs b/src/swarm/stats.rs
index eb34276..ab5c4da 100644
--- a/src/swarm/stats.rs
+++ b/src/swarm/stats.rs
@@ -33,6 +33,17 @@ struct Inner {
/// The document version (`AppState::change_tx`) and epoch the saved size is of.
measured_version: Option<(u64, Epoch)>,
propagation: Propagation,
+ disk: Disk,
+}
+
+/// Files this node reads and writes for itself: the state file, a backup to recover
+/// from. Not the Mycelium daemon's, and not logs.
+#[derive(Debug, Clone, Copy, Default)]
+pub(crate) struct Disk {
+ pub(crate) reads: u64,
+ pub(crate) read_bytes: u64,
+ pub(crate) writes: u64,
+ pub(crate) written_bytes: u64,
}
/// Upper bounds (inclusive, milliseconds) of the propagation delay buckets; a last
@@ -107,6 +118,7 @@ pub(crate) struct Snapshot {
pub(crate) max_heads: usize,
pub(crate) stale_hello_replies: u64,
pub(crate) propagation: Propagation,
+ pub(crate) disk: Disk,
}
impl Default for NodeStats {
@@ -151,6 +163,20 @@ impl NodeStats {
}
}
+ /// A file of `bytes` was read (`Disk`).
+ pub(crate) fn disk_read(&self, bytes: u64) {
+ let mut inner = self.lock();
+ inner.disk.reads += 1;
+ inner.disk.read_bytes += bytes;
+ }
+
+ /// A file of `bytes` was written (`Disk`).
+ pub(crate) fn disk_written(&self, bytes: u64) {
+ let mut inner = self.lock();
+ inner.disk.writes += 1;
+ inner.disk.written_bytes += bytes;
+ }
+
pub(crate) fn stale_hello_reply(&self) {
self.lock().stale_hello_replies += 1;
}
@@ -205,6 +231,7 @@ impl NodeStats {
max_heads: inner.max_heads,
stale_hello_replies: inner.stale_hello_replies,
propagation: inner.propagation,
+ disk: inner.disk,
}
}
}