Skip to content

Commit f98cbb8

Browse files
committed
Auto merge of #62340 - gnzlbg:mimalloc, r=<try>
[WIP] Switch rustc allocator to mimalloc [Here](https://www.microsoft.com/en-us/research/publication/mimalloc-free-list-sharding-in-action/), strong claims are made about the performance of mimalloc against pretty much every other widely-used allocator. This PR is the smallest-diff that hopefully allows us to do a perf run of rustc with mimalloc. Independently of the outcome, this is not intended to be merged upstream - hence tagged as WIP to prevent that. r? @Zoxc
2 parents 8c6fb02 + 23a20c3 commit f98cbb8

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

Cargo.lock

+11-18
Original file line numberDiff line numberDiff line change
@@ -992,11 +992,6 @@ dependencies = [
992992
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
993993
]
994994

995-
[[package]]
996-
name = "fs_extra"
997-
version = "1.1.0"
998-
source = "registry+https://github.com/rust-lang/crates.io-index"
999-
1000995
[[package]]
1001996
name = "fst"
1002997
version = "0.3.0"
@@ -1317,16 +1312,6 @@ name = "itoa"
13171312
version = "0.4.4"
13181313
source = "registry+https://github.com/rust-lang/crates.io-index"
13191314

1320-
[[package]]
1321-
name = "jemalloc-sys"
1322-
version = "0.3.0"
1323-
source = "registry+https://github.com/rust-lang/crates.io-index"
1324-
dependencies = [
1325-
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
1326-
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1327-
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
1328-
]
1329-
13301315
[[package]]
13311316
name = "jobserver"
13321317
version = "0.1.13"
@@ -1633,6 +1618,15 @@ name = "memoffset"
16331618
version = "0.2.1"
16341619
source = "registry+https://github.com/rust-lang/crates.io-index"
16351620

1621+
[[package]]
1622+
name = "mimalloc-sys"
1623+
version = "0.1.2"
1624+
source = "registry+https://github.com/rust-lang/crates.io-index"
1625+
dependencies = [
1626+
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
1627+
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
1628+
]
1629+
16361630
[[package]]
16371631
name = "minifier"
16381632
version = "0.0.30"
@@ -2642,7 +2636,7 @@ dependencies = [
26422636
name = "rustc-main"
26432637
version = "0.0.0"
26442638
dependencies = [
2645-
"jemalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
2639+
"mimalloc-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
26462640
"rustc_codegen_ssa 0.0.0",
26472641
"rustc_driver 0.0.0",
26482642
"rustc_target 0.0.0",
@@ -4296,7 +4290,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
42964290
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
42974291
"checksum fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3f8cbee5e872cf7db61a999a041f9bc4706ca7bf7df4cb914f53fabb1c1bc550"
42984292
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
4299-
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
43004293
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"
43014294
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
43024295
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
@@ -4331,7 +4324,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
43314324
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
43324325
"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
43334326
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
4334-
"checksum jemalloc-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bef0d4ce37578dfd80b466e3d8324bd9de788e249f1accebb0c472ea4b52bdc"
43354327
"checksum jobserver 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b3d51e24009d966c8285d524dbaf6d60926636b2a89caee9ce0bd612494ddc16"
43364328
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
43374329
"checksum jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "288dca7f9713710a29e485076b9340156cb701edb46a881f5d0c31aa4f5b9143"
@@ -4362,6 +4354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
43624354
"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39"
43634355
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
43644356
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
4357+
"checksum mimalloc-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "06bd52565989827e0d9342099892ef07703b66aba1c811ddb85c6aaaca23b04a"
43654358
"checksum minifier 0.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "4c909e78edf61f3aa0dd2086da168cdf304329044bbf248768ca3d20253ec8c0"
43664359
"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649"
43674360
"checksum miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ad30a47319c16cde58d0314f5d98202a80c9083b5f61178457403dfb14e509c"

src/rustc/Cargo.toml

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ rustc_driver = { path = "../librustc_driver" }
1616
# crate is intended to be used by codegen backends, which may not be in-tree.
1717
rustc_codegen_ssa = { path = "../librustc_codegen_ssa" }
1818

19-
[dependencies.jemalloc-sys]
20-
version = '0.3.0'
19+
#[dependencies.jemalloc-sys]
20+
#version = '0.3.0'
21+
#optional = true
22+
#features = ['unprefixed_malloc_on_supported_platforms']
23+
24+
[dependencies.mimalloc-sys]
25+
version = '0.1'
2126
optional = true
22-
features = ['unprefixed_malloc_on_supported_platforms']
2327

2428
[features]
25-
jemalloc = ['jemalloc-sys']
29+
jemalloc = ['mimalloc-sys']

src/rustc/rustc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ fn main() {
1313

1414
#[used]
1515
static _F1: unsafe extern fn(usize, usize) -> *mut c_void =
16-
jemalloc_sys::calloc;
16+
mimalloc_sys::calloc;
1717
#[used]
1818
static _F2: unsafe extern fn(*mut *mut c_void, usize, usize) -> c_int =
19-
jemalloc_sys::posix_memalign;
19+
mimalloc_sys::posix_memalign;
2020
#[used]
2121
static _F3: unsafe extern fn(usize, usize) -> *mut c_void =
22-
jemalloc_sys::aligned_alloc;
22+
mimalloc_sys::aligned_alloc;
2323
#[used]
2424
static _F4: unsafe extern fn(usize) -> *mut c_void =
25-
jemalloc_sys::malloc;
25+
mimalloc_sys::malloc;
2626
#[used]
2727
static _F5: unsafe extern fn(*mut c_void, usize) -> *mut c_void =
28-
jemalloc_sys::realloc;
28+
mimalloc_sys::realloc;
2929
#[used]
3030
static _F6: unsafe extern fn(*mut c_void) =
31-
jemalloc_sys::free;
31+
mimalloc_sys::free;
3232
}
3333

3434
rustc_driver::set_sigpipe_handler();

0 commit comments

Comments
 (0)