diff --git a/.github/scripts/allocator_bench_alpine.sh b/.github/scripts/allocator_bench_alpine.sh index 81ad1e4..14357c6 100755 --- a/.github/scripts/allocator_bench_alpine.sh +++ b/.github/scripts/allocator_bench_alpine.sh @@ -24,9 +24,9 @@ fi : > /work/alpine-results.tsv if [ -n "$features" ]; then - cargo build --release --locked --features "$features" + cargo build --no-default-features --release --locked --features "$features" else - cargo build --release --locked + cargo build --no-default-features --release --locked fi output="$(/usr/bin/time -v /work/target/release/proxy-scraper-checker 2>&1 >/dev/null)" diff --git a/.github/scripts/allocator_bench_unix.sh b/.github/scripts/allocator_bench_unix.sh index 106a22f..2005304 100755 --- a/.github/scripts/allocator_bench_unix.sh +++ b/.github/scripts/allocator_bench_unix.sh @@ -30,7 +30,7 @@ if [[ -n "$features" ]]; then feature_args=(--features "$features") fi -cargo build --release --locked "${feature_args[@]}" +cargo build --no-default-features --release --locked "${feature_args[@]}" exe="target/release/proxy-scraper-checker" if [[ "$RUNNER_OS" == "Windows" ]]; then diff --git a/.github/scripts/allocator_bench_windows.ps1 b/.github/scripts/allocator_bench_windows.ps1 index 7c98417..815886b 100644 --- a/.github/scripts/allocator_bench_windows.ps1 +++ b/.github/scripts/allocator_bench_windows.ps1 @@ -7,7 +7,7 @@ if ($allocator -ne "system") { $features += $allocator } if ($tokioFeature) { $features += $tokioFeature } $featuresString = $features -join "," -$args = @("build", "--release", "--locked") +$args = @("build", "--no-default-features", "--release", "--locked") if ($featuresString) { $args += "--features"; $args += $featuresString } Start-Process -FilePath "cargo" -ArgumentList $args -NoNewWindow -Wait diff --git a/.github/workflows/allocator-bench.yml b/.github/workflows/allocator-bench.yml index 7f5b003..ed9b25d 100644 --- a/.github/workflows/allocator-bench.yml +++ b/.github/workflows/allocator-bench.yml @@ -16,8 +16,11 @@ jobs: allocator: - system - jemalloc + - jemalloc_override - mimalloc_v2 + - mimalloc_v2_override - mimalloc_v3 + - mimalloc_v3_override tokio_multi_thread: [true, false] platform: - ubuntu-24.04-arm @@ -56,8 +59,12 @@ jobs: exclude: - platform: windows-2025 allocator: jemalloc + - platform: windows-2025 + allocator: jemalloc_override - platform: windows-11-arm allocator: jemalloc + - platform: windows-11-arm + allocator: jemalloc_override steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: diff --git a/Cargo.lock b/Cargo.lock index 5738f6d..6813ac6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -884,9 +884,9 @@ dependencies = [ [[package]] name = "hickory-resolver" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a10bd64d950b4d38ca21e25c8ae230712e4955fb8290cfcb29a5e5dc6017e544" +checksum = "f0d58d28879ceecde6607729660c2667a081ccdc082e082675042793960f178c" dependencies = [ "cfg-if", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 859b573..e7a863c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ foldhash = "=0.2.0" futures = { version = "=0.3.32", default-features = false, features = [ "std", ], optional = true } -hickory-resolver = "=0.26.0" +hickory-resolver = "=0.26.1" http = "=1.4.0" httpdate = "=1.0.3" ipnet = "=2.12.0" @@ -31,6 +31,7 @@ log = { version = "=0.4.29", features = [ "std", ] } maxminddb = { version = "=0.28.1", features = ["mmap"] } +mimalloc = { version = "=0.1.50", optional = true } parking_lot = "=0.12.5" rand = { version = "=0.10.1", default-features = false, features = [ "std", @@ -57,6 +58,7 @@ smallvec = { version = "=1.15.1", features = [ "union", ], optional = true } strum = { version = "=0.28.0", features = ["derive"], optional = true } +tikv-jemallocator = { version = "=0.6.1", optional = true } tokio = { version = "=1.52.1", features = ["fs", "parking_lot", "signal"] } tokio-util = "=0.7.18" toml = { version = "=1.1.2", default-features = false, features = [ @@ -75,17 +77,20 @@ tui-logger = { version = "=0.18.2", features = [ ], optional = true } url = "=2.5.8" -[target.'cfg(all(any(target_arch = "aarch64", target_arch = "x86_64"), any(target_os = "linux", target_os = "macos")))'.dependencies] -tikv-jemallocator = { version = "=0.6.1", optional = true } - -[target.'cfg(all(any(target_arch = "aarch64", target_arch = "x86_64"), any(target_os = "linux", target_os = "macos", target_os = "windows")))'.dependencies] -mimalloc = { version = "=0.1.50", optional = true } - [features] +# default = ["auto-allocator"] +__mimalloc = ["dep:mimalloc"] +auto-allocator = ["mimalloc_v3_override"] dhat = ["dep:dhat"] jemalloc = ["dep:tikv-jemallocator"] -mimalloc_v2 = ["dep:mimalloc", "mimalloc/v2"] -mimalloc_v3 = ["dep:mimalloc"] +jemalloc_override = [ + "jemalloc", + "tikv-jemallocator/unprefixed_malloc_on_supported_platforms" +] +mimalloc_v2 = ["__mimalloc", "mimalloc/v2"] +mimalloc_v2_override = ["mimalloc_v2", "mimalloc/override"] +mimalloc_v3 = ["__mimalloc"] +mimalloc_v3_override = ["mimalloc_v3", "mimalloc/override"] tokio-multi-thread = [] tui = [ "dep:crossterm", diff --git a/README.md b/README.md index 6f87a34..e0f7205 100644 --- a/README.md +++ b/README.md @@ -116,13 +116,13 @@ This tool makes thousands of concurrent network requests to test proxies, which 3. **Build release binary with TUI enabled** ```bash - cargo build --release --features tui + cargo build --features tui --release --locked ``` 4. **Run with TUI** ```bash - cargo run --release --features tui + cargo run --features tui --release --locked ``` **Binary location**: diff --git a/src/main.rs b/src/main.rs index 530ceeb..ce354a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,18 +73,17 @@ use tracing_subscriber::{ #[global_allocator] static GLOBAL: dhat::Alloc = dhat::Alloc; -#[cfg(all( - feature = "jemalloc", - any(target_arch = "aarch64", target_arch = "x86_64"), - any(target_os = "linux", target_os = "macos"), -))] +#[cfg(feature = "jemalloc")] #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; -#[cfg(all( - any(feature = "mimalloc_v2", feature = "mimalloc_v3"), - any(target_arch = "aarch64", target_arch = "x86_64"), - any(target_os = "linux", target_os = "macos", target_os = "windows"), +#[cfg(any( + all( + feature = "auto-allocator", + any(target_arch = "aarch64", target_arch = "x86_64"), + any(target_os = "linux", target_os = "macos", target_os = "windows"), + ), + feature = "__mimalloc" ))] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;