Skip to content

Commit 26d0fbb

Browse files
committed
tmp: try the mimalloc 3.0.1 alpha
1 parent b7c089b commit 26d0fbb

File tree

6 files changed

+45
-23
lines changed

6 files changed

+45
-23
lines changed

Cargo.lock

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,12 @@ dependencies = [
845845
"windows-sys 0.59.0",
846846
]
847847

848+
[[package]]
849+
name = "cty"
850+
version = "0.2.2"
851+
source = "registry+https://github.com/rust-lang/crates.io-index"
852+
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
853+
848854
[[package]]
849855
name = "curl"
850856
version = "0.4.47"
@@ -2072,6 +2078,16 @@ version = "0.2.11"
20722078
source = "registry+https://github.com/rust-lang/crates.io-index"
20732079
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
20742080

2081+
[[package]]
2082+
name = "libmimalloc-sys"
2083+
version = "0.1.39"
2084+
source = "git+https://github.com/lqd/mimalloc_rust.git?branch=mimalloc-3.0.1-alpha#d45656d2fda5f700e4a1a555b9c3560d2a64dc57"
2085+
dependencies = [
2086+
"cc",
2087+
"cty",
2088+
"libc",
2089+
]
2090+
20752091
[[package]]
20762092
name = "libredox"
20772093
version = "0.1.3"
@@ -3221,12 +3237,12 @@ checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497"
32213237
name = "rustc-main"
32223238
version = "0.0.0"
32233239
dependencies = [
3240+
"libmimalloc-sys",
32243241
"rustc_codegen_ssa",
32253242
"rustc_driver",
32263243
"rustc_driver_impl",
32273244
"rustc_smir",
32283245
"stable_mir",
3229-
"tikv-jemalloc-sys",
32303246
]
32313247

32323248
[[package]]

compiler/rustc/Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ rustc_smir = { path = "../rustc_smir" }
2020
stable_mir = { path = "../stable_mir" }
2121
# tidy-alphabetical-end
2222

23-
[dependencies.tikv-jemalloc-sys]
24-
version = "0.6.0"
23+
[dependencies.libmimalloc-sys]
24+
git = "https://github.com/lqd/mimalloc_rust.git"
25+
branch = "mimalloc-3.0.1-alpha"
2526
optional = true
26-
features = ['unprefixed_malloc_on_supported_platforms']
27+
default-features = false
28+
features = ["extended", "override"]
2729

2830
[features]
2931
# tidy-alphabetical-start
30-
jemalloc = ['dep:tikv-jemalloc-sys']
32+
jemalloc = ['dep:libmimalloc-sys']
3133
llvm = ['rustc_driver_impl/llvm']
3234
max_level_info = ['rustc_driver_impl/max_level_info']
3335
rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']

compiler/rustc/src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ fn main() {
4343
{
4444
use std::os::raw::{c_int, c_void};
4545

46-
use tikv_jemalloc_sys as jemalloc_sys;
47-
4846
#[used]
49-
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc;
47+
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = libmimalloc_sys::mi_calloc;
5048
#[used]
5149
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int =
52-
jemalloc_sys::posix_memalign;
50+
libmimalloc_sys::mi_posix_memalign;
5351
#[used]
54-
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc;
52+
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void =
53+
libmimalloc_sys::mi_aligned_alloc;
5554
#[used]
56-
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc;
55+
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = libmimalloc_sys::mi_malloc;
5756
#[used]
58-
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
57+
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void =
58+
libmimalloc_sys::mi_realloc;
5959
#[used]
60-
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;
60+
static _F6: unsafe extern "C" fn(*mut c_void) = libmimalloc_sys::mi_free;
6161

6262
// On OSX, jemalloc doesn't directly override malloc/free, but instead
6363
// registers itself with the allocator's zone APIs in a ctor. However,

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,11 +2080,12 @@ pub fn run_cargo(
20802080
// During check builds we need to keep crate metadata
20812081
keep = true;
20822082
} else if rlib_only_metadata {
2083-
if filename.contains("jemalloc_sys")
2083+
if filename.contains("libmimalloc_sys")
2084+
|| filename.contains("cty")
20842085
|| filename.contains("rustc_smir")
20852086
|| filename.contains("stable_mir")
20862087
{
2087-
// jemalloc_sys and rustc_smir are not linked into librustc_driver.so,
2088+
// libmimalloc_sys+cty and rustc_smir are not linked into librustc_driver.so,
20882089
// so we need to distribute them as rlib to be able to use them.
20892090
keep |= filename.ends_with(".rlib");
20902091
} else {

src/librustdoc/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extern crate test;
6868
// See docs in https://github.com/rust-lang/rust/blob/master/compiler/rustc/src/main.rs
6969
// about jemalloc.
7070
#[cfg(feature = "jemalloc")]
71-
extern crate tikv_jemalloc_sys as jemalloc_sys;
71+
extern crate libmimalloc_sys;
7272

7373
use std::env::{self, VarError};
7474
use std::io::{self, IsTerminal};
@@ -132,18 +132,20 @@ pub fn main() {
132132
use std::os::raw::{c_int, c_void};
133133

134134
#[used]
135-
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc;
135+
static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = libmimalloc_sys::mi_calloc;
136136
#[used]
137137
static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int =
138-
jemalloc_sys::posix_memalign;
138+
libmimalloc_sys::mi_posix_memalign;
139139
#[used]
140-
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc;
140+
static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void =
141+
libmimalloc_sys::mi_aligned_alloc;
141142
#[used]
142-
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc;
143+
static _F4: unsafe extern "C" fn(usize) -> *mut c_void = libmimalloc_sys::mi_malloc;
143144
#[used]
144-
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc;
145+
static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void =
146+
libmimalloc_sys::mi_realloc;
145147
#[used]
146-
static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free;
148+
static _F6: unsafe extern "C" fn(*mut c_void) = libmimalloc_sys::mi_free;
147149

148150
#[cfg(target_os = "macos")]
149151
{

src/tools/tidy/src/deps.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
266266
"crossbeam-utils",
267267
"crypto-common",
268268
"ctrlc",
269+
"cty",
269270
"darling",
270271
"darling_core",
271272
"darling_macro",
@@ -317,6 +318,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
317318
"leb128",
318319
"libc",
319320
"libloading",
321+
"libmimalloc-sys",
320322
"linux-raw-sys",
321323
"litemap",
322324
"lock_api",
@@ -396,7 +398,6 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
396398
"thiserror-impl",
397399
"thorin-dwp",
398400
"thread_local",
399-
"tikv-jemalloc-sys",
400401
"time",
401402
"time-core",
402403
"time-macros",

0 commit comments

Comments
 (0)