From 6273376770c597066aa9cfa380670b272c6c573e Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Fri, 20 Dec 2024 13:34:00 +0100 Subject: [PATCH] use jemalloc --- Cargo.lock | 21 +++++++++++++++++++++ Cargo.toml | 1 + src/antichess_tb.rs | 2 +- src/main.rs | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1e4b71a..478028a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -814,6 +814,7 @@ dependencies = [ "serde_with", "shakmaty", "shakmaty-syzygy", + "tikv-jemallocator", "tokio", "tower-http", "tracing", @@ -1421,6 +1422,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cec5ff18518d81584f477e9bfdf957f5bb0979b0bac3af4ca30b5b3ae2d2865" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.37" diff --git a/Cargo.toml b/Cargo.toml index 66d54a9..76a110b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ tower-http = { version = "0.6", features = ["trace"] } tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } tracing = "0.1" antichess-tb-sys = "0.1" +tikv-jemallocator = "0.6.0" [profile.release] lto = true diff --git a/src/antichess_tb.rs b/src/antichess_tb.rs index a3d888f..d43869e 100644 --- a/src/antichess_tb.rs +++ b/src/antichess_tb.rs @@ -63,7 +63,7 @@ pub unsafe fn probe_dtw(pos: &VariantPosition) -> Option { match result { 0 => Some(dtw as i32), 1 => Some(dtw as i32), // cursed win/loss - 2 => Some(0), // draw + 2 => Some(0), // draw error => { warn!("antichess tb probe failed with error code {error}"); None diff --git a/src/main.rs b/src/main.rs index 52760b7..706a48f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,7 @@ use clap::{builder::PathBufValueParser, ArgAction, CommandFactory as _, Parser}; use listenfd::ListenFd; use moka::future::Cache; use shakmaty_syzygy::filesystem::{MmapFilesystem, OsFilesystem}; +use tikv_jemallocator::Jemalloc; use tokio::net::TcpListener; use tower_http::trace::TraceLayer; use tracing::{info, info_span, trace, Instrument as _}; @@ -37,6 +38,9 @@ use crate::{ tablebases::Tablebases, }; +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + #[derive(Parser, Debug)] struct Opt { /// Directory with Syzygy tablebase files for standard chess.