Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(allocator): use mimalloc v2 for all #7361

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ rustflags = ["-C", "link-args=/FORCE"]
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
rustflags = ["-C", "target-feature=+crt-static"]
2 changes: 1 addition & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
target: ${{ inputs.target }}
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
profile: ${{ inputs.profile }}
pre: export JEMALLOC_SYS_WITH_LG_PAGE=16 && export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc # for jemallocator to compile
pre: export CC_aarch64_unknown_linux_gnu=clang

- name: Build x86_64-unknown-linux-musl in Docker
if: ${{ inputs.target == 'x86_64-unknown-linux-musl' && steps.check_cache.outputs.files_exists != 'true' && !inputs.skipable }}
Expand Down
58 changes: 15 additions & 43 deletions Cargo.lock

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

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ itertools = { version = "0.13.0" }
json = { version = "0.12.4" }
lightningcss = { version = "1.0.0-alpha.57" }
linked_hash_set = { version = "0.1.4" }
mimalloc-rust = { version = "0.2" }
mimalloc = { version = "0.1.43" }
mime_guess = { version = "2.0.4" }
once_cell = { version = "1.19.0" }
parcel_sourcemap = "2.1.1"
Expand Down Expand Up @@ -55,10 +55,9 @@ ustr = { package = "ustr-fxhash", version = "1.0.0" }
xxhash-rust = { version = "0.8.10" }

# Pinned
napi = { package = "napi-h", version = "=2.16.1" }
napi-build = { version = "2" }
napi-derive = { version = "2" }
tikv-jemallocator = { version = "=0.6.0", features = ["disable_initial_exec_tls"] }
napi = { package = "napi-h", version = "=2.16.1" }
napi-build = { version = "2" }
napi-derive = { version = "2" }

# Must be pinned with the same swc versions
#rkyv = { version = "=0.7.44" } # synced with swc wasm plugin
Expand Down
1 change: 1 addition & 0 deletions crates/node_binding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build:release:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release",
"build:release:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release",
"build:release:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release",
"build:release:musl": "cross-env RUST_TARGET=aarch64-unknown-linux-musl node scripts/build.js --release",
"build:release:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release",
"build:release-prod:all": "run-p build:release-prod:arm64 build:release-prod:x64 build:release-prod:linux && pnpm move-binding",
"build:release-prod": "node scripts/build.js --release-prod",
Expand Down
11 changes: 4 additions & 7 deletions crates/rspack_allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ version = "0.1.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[target.'cfg(target_os = "linux")'.dependencies]
# Turned on `local_dynamic_tls` to avoid issue: https://github.com/microsoft/mimalloc/issues/147
mimalloc = { workspace = true, features = ["local_dynamic_tls"] }

[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc-rust = { workspace = true }

[target.'cfg(all(target_os = "linux", target_env = "musl"))'.dependencies]
mimalloc-rust = { workspace = true, features = ["local-dynamic-tls"] }

[target.'cfg(all(target_os = "linux", target_env = "gnu", any(target_arch = "x86_64", target_arch = "aarch64")))'.dependencies]
tikv-jemallocator = { workspace = true }
mimalloc = { workspace = true }
15 changes: 2 additions & 13 deletions crates/rspack_allocator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
#[cfg(not(target_os = "linux"))]
#[global_allocator]
static GLOBAL: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;

#[cfg(all(target_os = "linux", target_env = "musl"))]
#[global_allocator]
static GLOBAL: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;
use mimalloc::MiMalloc;

#[cfg(all(
target_os = "linux",
target_env = "gnu",
any(target_arch = "x86_64", target_arch = "aarch64")
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
static GLOBAL: MiMalloc = MiMalloc;
Loading