diff --git a/Cargo.lock b/Cargo.lock index 49b4dd38..c3e26531 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2210,6 +2210,26 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "jobserver" version = "0.1.28" @@ -2515,6 +2535,7 @@ dependencies = [ "dashmap 5.5.3", "dotenv", "futures", + "jemallocator", "jsonrpsee", "lazy_static", "log", diff --git a/Cargo.toml b/Cargo.toml index 948e4596..b196f47f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ prometheus = "0.13.3" lazy_static = "1.4.0" dotenv = "0.15.0" async-channel = "1.8.0" +jemallocator = "0.5" quinn = "0.10.2" quinn-proto = "0.10.5" diff --git a/lite-rpc/Cargo.toml b/lite-rpc/Cargo.toml index 616006f7..c7b9268b 100644 --- a/lite-rpc/Cargo.toml +++ b/lite-rpc/Cargo.toml @@ -42,6 +42,7 @@ tokio = { version = "1.28.2", features = ["full", "fs"]} tokio-util = "0.7" tokio-postgres = { version = "0.7.8", features = ["with-chrono-0_4"] } chrono = { workspace = true } +jemallocator = { workspace = true } solana-lite-rpc-core = { workspace = true } solana-lite-rpc-services = { workspace = true } diff --git a/lite-rpc/src/main.rs b/lite-rpc/src/main.rs index 4cffed86..625fbf93 100644 --- a/lite-rpc/src/main.rs +++ b/lite-rpc/src/main.rs @@ -54,6 +54,11 @@ use tokio::sync::mpsc; use tokio::sync::RwLock; use tokio::time::{timeout, Instant}; +// jemalloc seems to be better at keeping the memory footprint reasonable over +// longer periods of time +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + async fn get_latest_block( mut block_stream: BlockStream, commitment_config: CommitmentConfig,