diff --git a/Cargo.lock b/Cargo.lock index a477676b..84ee8c26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2585,6 +2585,7 @@ dependencies = [ "futures-util", "hyper", "itertools 0.10.5", + "jemalloc-ctl", "jemallocator", "jsonrpsee", "lazy_static", diff --git a/lite-rpc/Cargo.toml b/lite-rpc/Cargo.toml index 0ad19bb2..b9c31436 100644 --- a/lite-rpc/Cargo.toml +++ b/lite-rpc/Cargo.toml @@ -50,7 +50,8 @@ cap = { version = "0.1.2", features = ["stats"] } tower = "0.4.13" hyper = { version = "0.14", features = ["server", "http1", "http2"] } tower-http = { version = "0.4.0", features = ["full"] } -jemallocator = { workspace = true } +jemallocator = { workspace = true, features = ["profiling"] } +jemalloc-ctl = "0.5.4" solana-lite-rpc-core = { workspace = true } solana-lite-rpc-util = { workspace = true } diff --git a/lite-rpc/src/main.rs b/lite-rpc/src/main.rs index 5266fe62..36746091 100644 --- a/lite-rpc/src/main.rs +++ b/lite-rpc/src/main.rs @@ -76,6 +76,12 @@ use tracing_subscriber::EnvFilter; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; +// export _RJEM_MALLOC_CONF=prof:true,lg_prof_interval:30,lg_prof_sample:21,prof_prefix:/tmp/jeprof + +use jemalloc_ctl::{epoch, stats}; +use std::{thread, time::{self}}; + + async fn get_latest_block_info( mut blockinfo_stream: BlockInfoStream, commitment_config: CommitmentConfig, @@ -395,6 +401,30 @@ pub async fn start_lite_rpc(args: Config, rpc_client: Arc) -> anyhow: )); drop(slot_notifier); + // tokio::spawn(async move { + + // let last_allocated = stats::allocated::read().unwrap(); + // let last_resident = stats::resident::read().unwrap(); + // let last_mapped = stats::mapped::read().unwrap(); + // let last_active = stats::active::read().unwrap(); + + // loop { + // thread::sleep(time::Duration::from_secs(10)); + // // Retrieve memory statistics + // // let stats = stats::active::mib().unwrap().read().unwrap(); + + // let allocated = stats::allocated::read().unwrap(); + // let resident = stats::resident::read().unwrap(); + // let mapped = stats::mapped::read().unwrap(); + // let active = stats::active::read().unwrap(); + + // info!("Current allocated memory: {} bytes -- diff {}", allocated, last_allocated as i64 - allocated as i64); + // info!("Current resident memory: {} bytes -- diff {}", resident, last_resident as i64 - resident as i64); + // info!("Current mapped memory: {} bytes -- diff {}", mapped, last_mapped as i64 - mapped as i64); + // info!("Current active memory: {} bytes -- diff {}\n", active, last_active as i64 - active as i64); + // } + // }); + tokio::select! { res = tx_service_jh => { anyhow::bail!("Tx Services {res:?}") diff --git a/services-integration-test/tests/txn_broadcast.rs b/services-integration-test/tests/txn_broadcast.rs index a6e1c4eb..b1b4956e 100644 --- a/services-integration-test/tests/txn_broadcast.rs +++ b/services-integration-test/tests/txn_broadcast.rs @@ -11,7 +11,6 @@ use tokio::time::Instant; use crate::setup::setup_tx_service; -use jemalloc_ctl::{epoch, stats}; mod setup; @@ -27,29 +26,7 @@ pub async fn txn_broadcast() -> anyhow::Result<()> { tracing_subscriber::fmt::init(); info!("START BENCHMARK: txn_broadcast"); - tokio::spawn(async move { - let mut last_allocated = stats::allocated::read().unwrap(); - let mut last_resident = stats::resident::read().unwrap(); - let mut last_mapped = stats::mapped::read().unwrap(); - let mut last_active = stats::active::read().unwrap(); - - loop { - thread::sleep(time::Duration::from_secs(10)); - // Retrieve memory statistics - // let stats = stats::active::mib().unwrap().read().unwrap(); - - let allocated = stats::allocated::read().unwrap(); - let resident = stats::resident::read().unwrap(); - let mapped = stats::mapped::read().unwrap(); - let active = stats::active::read().unwrap(); - - info!("Current allocated memory: {} bytes -- diff {}", allocated, last_allocated as i64 - allocated as i64); - info!("Current resident memory: {} bytes -- diff {}", resident, last_resident as i64 - resident as i64); - info!("Current mapped memory: {} bytes -- diff {}", mapped, last_mapped as i64 - mapped as i64); - info!("Current active memory: {} bytes -- diff {}", active, last_active as i64 - active as i64); - } - }); debug!("spawning tx_service"); let (transaction_service, data_cache, _tx_jh) = setup_tx_service().await?;