Skip to content

Commit

Permalink
Try using jemalloc on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Jan 8, 2024
1 parent f7d32c3 commit c255ce9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install Cygwin
uses: cygwin/cygwin-install-action@v4
- uses: actions/cache@v3
with:
path: |
Expand Down
23 changes: 1 addition & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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
10 changes: 1 addition & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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},
Expand Down Expand Up @@ -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<String> = Lazy::new(|| {
format!(
Expand Down

0 comments on commit c255ce9

Please sign in to comment.