From ca281d363a5b059eae6ae1a1119fd9b094ddb3c5 Mon Sep 17 00:00:00 2001 From: james58899 Date: Mon, 8 Jan 2024 07:20:35 +0000 Subject: [PATCH] Try snmalloc --- Cargo.lock | 70 ++++++++++++++++++++++------------------------------- Cargo.toml | 7 +----- src/main.rs | 10 +------- 3 files changed, 31 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d56846a..b84cf09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -835,6 +835,15 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "cocoa" version = "0.25.0" @@ -1758,7 +1767,6 @@ dependencies = [ "hyper", "inquire", "log", - "mimalloc", "mime", "once_cell", "openssl", @@ -1769,10 +1777,10 @@ dependencies = [ "regex", "reqwest", "scopeguard", + "snmalloc-rs", "socket2 0.5.5", "tao", "tempfile", - "tikv-jemallocator", "tokio", "tokio-stream", "tray-icon", @@ -2109,16 +2117,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libmimalloc-sys" -version = "0.1.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "libredox" version = "0.0.1" @@ -2226,15 +2224,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mimalloc" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" -dependencies = [ - "libmimalloc-sys", -] - [[package]] name = "mime" version = "0.3.17" @@ -3104,6 +3093,25 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +[[package]] +name = "snmalloc-rs" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038507ad9c0ff0d6901e057494abcdba49a1a44fe3236f281730a9278166710d" +dependencies = [ + "snmalloc-sys", +] + +[[package]] +name = "snmalloc-sys" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cae3f7f662ebf11afe4d6534e63fa5846ec0143892c78ddb1040cc01249f143" +dependencies = [ + "cc", + "cmake", +] + [[package]] name = "socket2" version = "0.4.10" @@ -3309,26 +3317,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "tikv-jemallocator" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" -dependencies = [ - "libc", - "tikv-jemalloc-sys", -] - [[package]] name = "time" version = "0.3.31" diff --git a/Cargo.toml b/Cargo.toml index ecdce91..5e4d04d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,17 +29,12 @@ rand = { version = "0.8", default-features = false, features = ["small_rng"] } regex = "1.10" reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "stream", "socks"] } scopeguard = "1.2" +snmalloc-rs = { version = "0.3", features = ["build_cc"] } socket2 = "0.5" tempfile = "3.8" tokio = { version = "1", features = ["full", "parking_lot"] } tokio-stream = { version = "0.1", default-features = false, features = ["fs"] } -[target.'cfg(not(target_env = "msvc"))'.dependencies] -tikv-jemallocator = { version = "0.5", features = ["background_threads", "unprefixed_malloc_on_supported_platforms"] } - -[target.'cfg(target_env = "msvc")'.dependencies] -mimalloc = { version = "0.1", default-features = false } - [target.'cfg(windows)'.dependencies] tray-icon = { version = "0.11", default-features = false } windows = { version = "*", features = ["Win32_Foundation", "Win32_System_Console", "Win32_UI_WindowsAndMessaging"] } diff --git a/src/main.rs b/src/main.rs index 46d3802..481b448 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,8 +25,6 @@ use inquire::{ CustomType, Text, }; use log::{error, info, warn}; -#[cfg(target_env = "msvc")] -use mimalloc::MiMalloc; use once_cell::sync::Lazy; use openssl::{ pkcs12::ParsedPkcs12_2, @@ -36,8 +34,6 @@ use parking_lot::{Mutex, RwLock}; use regex::Regex; use reqwest::Proxy; use tempfile::TempPath; -#[cfg(not(target_env = "msvc"))] -use tikv_jemallocator::Jemalloc; use tokio::{ fs::{self, try_exists, File}, io::{stderr, stdin, AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader}, @@ -68,12 +64,8 @@ mod rpc; mod rpc_http_client; mod util; -#[cfg(not(target_env = "msvc"))] #[global_allocator] -static GLOBAL: Jemalloc = Jemalloc; -#[cfg(target_env = "msvc")] -#[global_allocator] -static GLOBAL: MiMalloc = MiMalloc; +static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc; static VERSION: Lazy = Lazy::new(|| { format!(