From 2a304c2b6c4f0b29afe1786e299f7cb1d1836f86 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 9 Jul 2024 21:22:44 +0000 Subject: [PATCH] add some usage stats output on the mutex maps Signed-off-by: Jason Volk --- src/service/rooms/event_handler/mod.rs | 15 +++++++++++++++ src/service/rooms/state/mod.rs | 8 ++++++++ src/service/rooms/timeline/mod.rs | 3 +++ 3 files changed, 26 insertions(+) diff --git a/src/service/rooms/event_handler/mod.rs b/src/service/rooms/event_handler/mod.rs index bf553d5c..9490a404 100644 --- a/src/service/rooms/event_handler/mod.rs +++ b/src/service/rooms/event_handler/mod.rs @@ -3,6 +3,7 @@ mod signing_keys; use std::{ collections::{hash_map, BTreeMap, HashMap, HashSet}, + fmt::Write, pin::Pin, sync::{Arc, RwLock as StdRwLock}, time::Instant, @@ -61,6 +62,20 @@ impl crate::Service for Service { })) } + fn memory_usage(&self, out: &mut dyn Write) -> Result<()> { + let mutex_federation = self.mutex_federation.len(); + writeln!(out, "federation_mutex: {mutex_federation}")?; + + let federation_handletime = self + .federation_handletime + .read() + .expect("locked for reading") + .len(); + writeln!(out, "federation_handletime: {federation_handletime}")?; + + Ok(()) + } + fn name(&self) -> &str { crate::service::make_name(std::module_path!()) } } diff --git a/src/service/rooms/state/mod.rs b/src/service/rooms/state/mod.rs index 7d89ee33..a3a317a5 100644 --- a/src/service/rooms/state/mod.rs +++ b/src/service/rooms/state/mod.rs @@ -2,6 +2,7 @@ mod data; use std::{ collections::{HashMap, HashSet}, + fmt::Write, sync::Arc, }; @@ -40,6 +41,13 @@ impl crate::Service for Service { })) } + fn memory_usage(&self, out: &mut dyn Write) -> Result<()> { + let mutex = self.mutex.len(); + writeln!(out, "state_mutex: {mutex}")?; + + Ok(()) + } + fn name(&self) -> &str { crate::service::make_name(std::module_path!()) } } diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index df2d46bd..e255e978 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -92,6 +92,9 @@ impl crate::Service for Service { .len(); writeln!(out, "lasttimelinecount_cache: {lasttimelinecount_cache}")?; + let mutex_insert = self.mutex_insert.len(); + writeln!(out, "insert_mutex: {mutex_insert}")?; + Ok(()) }