From ddb87aa1511b3278642ec8ad2f9e6a072b19c323 Mon Sep 17 00:00:00 2001 From: james58899 Date: Mon, 8 Jan 2024 17:06:12 +0000 Subject: [PATCH] Try using jemalloc on windows --- .github/workflows/rust.yml | 9 +++++++++ Cargo.lock | 23 +---------------------- Cargo.toml | 10 ++++------ src/main.rs | 10 +--------- 4 files changed, 15 insertions(+), 37 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ed680ec..50eb4af 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -63,6 +63,15 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v3 + - name: Install Cygwin + uses: cygwin/cygwin-install-action@v4 + with: + packages: >- + autoconf + autogen + gawk + grep + sed - uses: actions/cache@v3 with: path: | diff --git a/Cargo.lock b/Cargo.lock index d56846a..66ecb86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1758,7 +1758,6 @@ dependencies = [ "hyper", "inquire", "log", - "mimalloc", "mime", "once_cell", "openssl", @@ -2109,16 +2108,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 +2215,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" @@ -3312,8 +3292,7 @@ dependencies = [ [[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" +source = "git+https://github.com/james58899/jemallocator?rev=d42449d#d42449d877f616e1a2bb3085f0216a6c20dfeb97" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index ecdce91..eec0c46 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,15 +31,10 @@ reqwest = { version = "0.11", default-features = false, features = ["rustls-tls" scopeguard = "1.2" socket2 = "0.5" tempfile = "3.8" +tikv-jemallocator = { version = "0.5", features = ["background_threads", "unprefixed_malloc_on_supported_platforms"] } 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"] } @@ -49,6 +44,9 @@ tao = "0.24" built = { version = "0.7", features = ["git2", "chrono", "semver"] } openssl-src = { version = "300", features = ["weak-crypto"] } +[patch.crates-io] +tikv-jemalloc-sys = { git = 'https://github.com/james58899/jemallocator', rev = 'd42449d' } + [profile.release] lto = true strip = true diff --git a/src/main.rs b/src/main.rs index 46d3802..5e79c37 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 GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; static VERSION: Lazy = Lazy::new(|| { format!(