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

[WIP-test run] switch rustc allocator to mimalloc #64495

Closed
wants to merge 10 commits into from
Closed
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
29 changes: 11 additions & 18 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1044,12 +1044,6 @@ dependencies = [
"winapi 0.3.6",
]

[[package]]
name = "fs_extra"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"

[[package]]
name = "fst"
version = "0.3.0"
Expand Down Expand Up @@ -1491,17 +1485,6 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"

[[package]]
name = "jemalloc-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bef0d4ce37578dfd80b466e3d8324bd9de788e249f1accebb0c472ea4b52bdc"
dependencies = [
"cc",
"fs_extra",
"libc",
]

[[package]]
name = "jobserver"
version = "0.1.16"
Expand Down Expand Up @@ -1926,6 +1909,16 @@ dependencies = [
"rustc_version",
]

[[package]]
name = "mimalloc-sys"
version = "0.1.6-dev"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8943b38257eabf485d80499e273afbcbec16b1b581efc611230e3cda8c9b5e40"
dependencies = [
"cc",
"libc",
]

[[package]]
name = "mime"
version = "0.3.13"
Expand Down Expand Up @@ -3193,7 +3186,7 @@ dependencies = [
name = "rustc-main"
version = "0.0.0"
dependencies = [
"jemalloc-sys",
"mimalloc-sys",
"rustc_codegen_ssa",
"rustc_driver",
"rustc_target",
Expand Down
17 changes: 13 additions & 4 deletions src/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ rustc_driver = { path = "../librustc_driver" }
# crate is intended to be used by codegen backends, which may not be in-tree.
rustc_codegen_ssa = { path = "../librustc_codegen_ssa" }

[dependencies.jemalloc-sys]
version = '0.3.0'
#[dependencies.jemalloc-sys]
#version = '0.3.0'
#optional = true
#features = ['unprefixed_malloc_on_supported_platforms']

[dependencies.mimalloc-sys]
version = '=0.1.6-dev'
optional = true
features = ['unprefixed_malloc_on_supported_platforms']

[features]
jemalloc = ['jemalloc-sys']
jemalloc = [
'mimalloc-sys',
'mimalloc-sys/override',
# 'mimalloc-sys/secure', #FIXME: disable secure build
'mimalloc-sys/check_full'
]
20 changes: 10 additions & 10 deletions src/rustc/rustc.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
fn main() {
// Pull in jemalloc when enabled.
// Pull in mimalloc when enabled.
//
// Note that we're pulling in a static copy of jemalloc which means that to
// Note that we're pulling in a static copy of mimalloc which means that to
// pull it in we need to actually reference its symbols for it to get
// linked. The two crates we link to here, std and rustc_driver, are both
// dynamic libraries. That means to pull in jemalloc we need to actually
// dynamic libraries. That means to pull in mimalloc we need to actually
// reference allocation symbols one way or another (as this file is the only
// object code in the rustc executable).
#[cfg(feature = "jemalloc-sys")]
#[cfg(feature = "mimalloc-sys")]
{
use std::os::raw::{c_void, c_int};

#[used]
static _F1: unsafe extern fn(usize, usize) -> *mut c_void =
jemalloc_sys::calloc;
mimalloc_sys::calloc;
#[used]
static _F2: unsafe extern fn(*mut *mut c_void, usize, usize) -> c_int =
jemalloc_sys::posix_memalign;
mimalloc_sys::posix_memalign;
#[used]
static _F3: unsafe extern fn(usize, usize) -> *mut c_void =
jemalloc_sys::aligned_alloc;
mimalloc_sys::aligned_alloc;
#[used]
static _F4: unsafe extern fn(usize) -> *mut c_void =
jemalloc_sys::malloc;
mimalloc_sys::malloc;
#[used]
static _F5: unsafe extern fn(*mut c_void, usize) -> *mut c_void =
jemalloc_sys::realloc;
mimalloc_sys::realloc;
#[used]
static _F6: unsafe extern fn(*mut c_void) =
jemalloc_sys::free;
mimalloc_sys::free;
}

rustc_driver::set_sigpipe_handler();
Expand Down