diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-03-11 17:26:32 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-03-11 17:26:32 +0100 |
| commit | e1286892e59a6ca2fc44a58473ca45292e623a10 (patch) | |
| tree | 36389b06f5be667e4f13cfb1e62db4d228e75343 /cache/src | |
| parent | 578b32c9119692fb049fa56c7d52f2fbb8d485d7 (diff) | |
| download | jellything-e1286892e59a6ca2fc44a58473ca45292e623a10.tar jellything-e1286892e59a6ca2fc44a58473ca45292e623a10.tar.bz2 jellything-e1286892e59a6ca2fc44a58473ca45292e623a10.tar.zst | |
debug info page for db kv and cache kv
Diffstat (limited to 'cache/src')
| -rw-r--r-- | cache/src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cache/src/lib.rs b/cache/src/lib.rs index 0a7a2f1..117b0d2 100644 --- a/cache/src/lib.rs +++ b/cache/src/lib.rs @@ -7,12 +7,14 @@ mod helper; use anyhow::{Context, Result, anyhow}; pub use helper::{EscapeKey, HashKey}; +use humansize::{DECIMAL, SizeFormatter}; use jellykv::BlobStorage; use log::{info, warn}; use serde::{Deserialize, Serialize}; use std::{ any::Any, collections::{BTreeMap, HashMap}, + fmt::Write, hash::{DefaultHasher, Hash, Hasher}, sync::{ Arc, LazyLock, Mutex, RwLock, @@ -168,4 +170,15 @@ impl Cache { humansize::format_size(reduction, humansize::DECIMAL) ); } + + pub fn debug_info(&self) -> Result<String> { + let mut o = String::new(); + let msize = self.memory_cache_size.load(Ordering::Relaxed); + let mcount = self.memory_cache.read().unwrap().len(); + let msize = SizeFormatter::new(msize, DECIMAL).to_string(); + writeln!(o, "in-memory cache size: {msize:>12}")?; + writeln!(o, "in-memory cache obj count: {mcount:>12}")?; + write!(o, "{}", self.storage.debug_info()?)?; + Ok(o) + } } |