diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-17 16:42:39 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-17 16:42:39 +0100 |
commit | 026c6345770592246a7d31d323ff1c8631d08fed (patch) | |
tree | 57139cfbc39b6c7b657e7c5b5fac01e6c21bd75b /src | |
parent | d31212e56bc81f9d5648817fa366ac5565e46883 (diff) | |
download | tricot-do-not-merge/hprof.tar.gz tricot-do-not-merge/hprof.zip |
jeprof, jemalloc & friendsdo-not-merge/hprof
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | src/metrics.rs | 5 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 93abcca..5ccc2fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,9 +24,12 @@ mod tls_util; pub use df_consul as consul; use proxy_config::ProxyConfig; -#[cfg(feature = "dhat-heap")] +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] #[global_allocator] -static ALLOC: dhat::Alloc = dhat::Alloc; +static GLOBAL: Jemalloc = Jemalloc; #[derive(StructOpt, Debug)] #[structopt(name = "tricot")] @@ -110,6 +113,7 @@ struct Opt { pub warmup_cert_memory_store: bool, } + #[tokio::main(flavor = "multi_thread", worker_threads = 10)] async fn main() { #[cfg(feature = "dhat-heap")] @@ -210,7 +214,8 @@ async fn main() { .then(|_| async { info!("HTTPS server exited") }), ); - let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone())); + let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone())); + metrics_task.await.expect("Tokio task await failure"); http_task.await.expect("Tokio task await failure"); diff --git a/src/metrics.rs b/src/metrics.rs index d9ad372..16720f0 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -70,6 +70,11 @@ impl MetricsServer { debug!("{} {}", req.method(), req.uri()); let response = match (req.method(), req.uri().path()) { + (&Method::GET, "/hprof") => { + let buff = common_mem_prof::dump_profile().await.unwrap(); + tokio::fs::write("memdump.hprof", buff).await.unwrap(); + Response::builder().status(204).body(Body::from(vec![])).unwrap() + }, (&Method::GET, "/metrics") => { let mut buffer = vec![]; let encoder = TextEncoder::new(); |