Skip to content

Commit 6fc64b2

Browse files
authored
[WIP] Swap jemalloc to mimalloc
* Swap jemalloc to mimalloc * Fix aligned alloc. * Bump libmimalloc-sys. * Include lock-file.
1 parent e708cbd commit 6fc64b2

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

Cargo.lock

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,12 @@ dependencies = [
901901
"syn",
902902
]
903903

904+
[[package]]
905+
name = "cty"
906+
version = "0.2.1"
907+
source = "registry+https://github.com/rust-lang/crates.io-index"
908+
checksum = "7313c0d620d0cb4dbd9d019e461a4beb501071ff46ec0ab933efb4daa76d73e3"
909+
904910
[[package]]
905911
name = "curl"
906912
version = "0.4.34"
@@ -1216,12 +1222,6 @@ dependencies = [
12161222
"rustc-std-workspace-core",
12171223
]
12181224

1219-
[[package]]
1220-
name = "fs_extra"
1221-
version = "1.1.0"
1222-
source = "registry+https://github.com/rust-lang/crates.io-index"
1223-
checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
1224-
12251225
[[package]]
12261226
name = "fst"
12271227
version = "0.3.5"
@@ -1612,17 +1612,6 @@ version = "0.4.6"
16121612
source = "registry+https://github.com/rust-lang/crates.io-index"
16131613
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
16141614

1615-
[[package]]
1616-
name = "jemalloc-sys"
1617-
version = "0.3.2"
1618-
source = "registry+https://github.com/rust-lang/crates.io-index"
1619-
checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45"
1620-
dependencies = [
1621-
"cc",
1622-
"fs_extra",
1623-
"libc",
1624-
]
1625-
16261615
[[package]]
16271616
name = "jobserver"
16281617
version = "0.1.21"
@@ -1805,6 +1794,16 @@ dependencies = [
18051794
"pkg-config",
18061795
]
18071796

1797+
[[package]]
1798+
name = "libmimalloc-sys"
1799+
version = "0.1.20"
1800+
source = "registry+https://github.com/rust-lang/crates.io-index"
1801+
checksum = "e58f42b6424a0ed536678c65fd97cd64b4344bcf86251e284f7c0ce9eee40e64"
1802+
dependencies = [
1803+
"cmake",
1804+
"cty",
1805+
]
1806+
18081807
[[package]]
18091808
name = "libnghttp2-sys"
18101809
version = "0.1.4+1.41.0"
@@ -3406,7 +3405,7 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
34063405
name = "rustc-main"
34073406
version = "0.0.0"
34083407
dependencies = [
3409-
"jemalloc-sys",
3408+
"libmimalloc-sys",
34103409
"rustc_codegen_ssa",
34113410
"rustc_driver",
34123411
]

compiler/rustc/Cargo.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ rustc_driver = { path = "../rustc_driver" }
1111
# crate is intended to be used by codegen backends, which may not be in-tree.
1212
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
1313

14-
[dependencies.jemalloc-sys]
15-
version = '0.3.0'
14+
#[dependencies.jemalloc-sys]
15+
#version = '0.3.0'
16+
#optional = true
17+
#features = ['unprefixed_malloc_on_supported_platforms']
18+
19+
[dependencies.libmimalloc-sys]
20+
version = "0.1.20"
1621
optional = true
17-
features = ['unprefixed_malloc_on_supported_platforms']
22+
default-features = false
23+
features = ["extended", "override"]
1824

1925
[features]
20-
jemalloc = ['jemalloc-sys']
26+
jemalloc = ['libmimalloc-sys']
2127
llvm = ['rustc_driver/llvm']
2228
max_level_info = ['rustc_driver/max_level_info']

compiler/rustc/src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ fn main() {
77
// dynamic libraries. That means to pull in jemalloc we need to actually
88
// reference allocation symbols one way or another (as this file is the only
99
// object code in the rustc executable).
10-
#[cfg(feature = "jemalloc-sys")]
10+
#[cfg(feature = "libmimalloc-sys")]
1111
{
1212
use std::os::raw::{c_int, c_void};
1313

1414
#[used]
15-
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc;
15+
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = libmimalloc_sys::mi_calloc;
1616
#[used]
1717
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int =
18-
jemalloc_sys::posix_memalign;
18+
libmimalloc_sys::mi_posix_memalign;
1919
#[used]
20-
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc;
20+
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = libmimalloc_sys::mi_aligned_alloc;
2121
#[used]
22-
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc;
22+
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = libmimalloc_sys::mi_malloc;
2323
#[used]
24-
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
24+
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = libmimalloc_sys::mi_realloc;
2525
#[used]
26-
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;
26+
static _F6: unsafe extern "C" fn(*mut c_void) = libmimalloc_sys::mi_free;
2727
}
2828

2929
rustc_driver::set_sigpipe_handler();

0 commit comments

Comments
 (0)