start mallctl suite w/ jemalloc stats

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-27 04:50:20 -07:00 committed by June
parent 56f652c12d
commit e4b669360f
9 changed files with 101 additions and 14 deletions

View file

@ -453,3 +453,7 @@ pub(crate) async fn resolve_true_destination(
"Actual destination: {actual_dest:?} | Hostname URI: {hostname_uri}"
)))
}
pub(crate) fn memory_stats() -> RoomMessageEventContent {
RoomMessageEventContent::text_html("HTML only".to_owned(), crate::alloc::memory_stats())
}

View file

@ -3,7 +3,7 @@ use ruma::{events::room::message::RoomMessageEventContent, EventId, RoomId, Serv
use self::debug_commands::{
change_log_level, force_device_list_updates, get_auth_chain, get_pdu, get_remote_pdu, get_remote_pdu_list,
get_room_state, parse_pdu, ping, resolve_true_destination, sign_json, verify_json,
get_room_state, memory_stats, parse_pdu, ping, resolve_true_destination, sign_json, verify_json,
};
use crate::Result;
@ -117,6 +117,9 @@ pub(crate) enum DebugCommand {
#[arg(short, long)]
no_cache: bool,
},
/// - Print extended memory usage
MemoryStats,
}
pub(crate) async fn process(command: DebugCommand, body: Vec<&str>) -> Result<RoomMessageEventContent> {
@ -153,5 +156,6 @@ pub(crate) async fn process(command: DebugCommand, body: Vec<&str>) -> Result<Ro
server_name,
no_cache,
} => resolve_true_destination(body, server_name, no_cache).await?,
DebugCommand::MemoryStats => memory_stats(),
})
}

View file

@ -26,11 +26,12 @@ pub(crate) async fn show_config(_body: Vec<&str>) -> Result<RoomMessageEventCont
}
pub(crate) async fn memory_usage(_body: Vec<&str>) -> Result<RoomMessageEventContent> {
let response1 = services().memory_usage().await;
let response2 = services().globals.db.memory_usage();
let response0 = services().memory_usage().await;
let response1 = services().globals.db.memory_usage();
let response2 = crate::alloc::memory_usage();
Ok(RoomMessageEventContent::text_plain(format!(
"Services:\n{response1}\n\nDatabase:\n{response2}"
"Services:\n{response0}\n\nDatabase:\n{response1}\nAllocator:\n{response2}"
)))
}