Skip to content

Commit 7200826

Browse files
feat: switch to jemalloc allocator
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
1 parent 7a0e728 commit 7200826

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Cargo.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ mockall_double = "0.3"
4747
axum = { version = "0.7.5", features = ["macros", "query"] }
4848
axum-server = { version = "0.6", features = ["tls-rustls"] }
4949
tower-http = { version = "0.5.2", features = ["trace"] }
50+
tikv-jemallocator = { version = "0.5.4", features = [
51+
"unprefixed_malloc_on_supported_platforms",
52+
] }
5053

5154
[dev-dependencies]
5255
mockall = "0.12"

src/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ use policy_server::metrics::setup_metrics;
1010
use policy_server::tracing::setup_tracing;
1111
use policy_server::PolicyServer;
1212

13+
use tikv_jemallocator::Jemalloc;
14+
15+
#[global_allocator]
16+
static GLOBAL: Jemalloc = Jemalloc;
17+
18+
#[allow(non_upper_case_globals)]
19+
#[export_name = "malloc_conf"]
20+
pub static malloc_conf: &[u8] = b"background_thread:true,tcache_max:4096,dirty_decay_ms:5000,muzzy_decay_ms:5000,abort_conf:true\0";
21+
1322
#[tokio::main]
1423
async fn main() -> Result<()> {
1524
let matches = cli::build_cli().get_matches();

0 commit comments

Comments
 (0)