Skip to content

Commit 6819e3c

Browse files
committed
tmp: try to use jemalloc via #[global_allocator]
1 parent e08b80c commit 6819e3c

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,16 @@ dependencies = [
18851885
"libc",
18861886
]
18871887

1888+
[[package]]
1889+
name = "jemallocator"
1890+
version = "0.5.4"
1891+
source = "registry+https://github.com/rust-lang/crates.io-index"
1892+
checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc"
1893+
dependencies = [
1894+
"jemalloc-sys",
1895+
"libc",
1896+
]
1897+
18881898
[[package]]
18891899
name = "jobserver"
18901900
version = "0.1.31"
@@ -3573,6 +3583,7 @@ name = "rustc_driver_impl"
35733583
version = "0.0.0"
35743584
dependencies = [
35753585
"ctrlc",
3586+
"jemallocator",
35763587
"libc",
35773588
"rustc_ast",
35783589
"rustc_ast_lowering",

compiler/rustc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ features = ['unprefixed_malloc_on_supported_platforms']
2727

2828
[features]
2929
# tidy-alphabetical-start
30-
jemalloc = ['dep:jemalloc-sys']
30+
jemalloc = ['dep:jemalloc-sys', 'rustc_driver_impl/jemalloc']
3131
llvm = ['rustc_driver_impl/llvm']
3232
max_level_info = ['rustc_driver_impl/max_level_info']
3333
rustc_use_parallel_compiler = ['rustc_driver_impl/rustc_use_parallel_compiler']

compiler/rustc_driver_impl/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ features = [
6868
ctrlc = "3.4.4"
6969
# tidy-alphabetical-end
7070

71+
[dependencies.jemallocator]
72+
version = "0.5.4"
73+
optional = true
74+
features = ['unprefixed_malloc_on_supported_platforms']
75+
7176
[features]
7277
# tidy-alphabetical-start
78+
jemalloc = ['dep:jemallocator']
7379
llvm = ['rustc_interface/llvm']
7480
max_level_info = ['rustc_log/max_level_info']
7581
rustc_use_parallel_compiler = [

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,14 @@ pub fn install_ctrlc_handler() {
15751575
}
15761576

15771577
pub fn main() -> ! {
1578+
#[cfg(feature = "jemalloc")]
1579+
{
1580+
use jemallocator::Jemalloc;
1581+
1582+
#[global_allocator]
1583+
static GLOBAL: Jemalloc = Jemalloc;
1584+
}
1585+
15781586
let start_time = Instant::now();
15791587
let start_rss = get_resident_set_size();
15801588

src/tools/tidy/src/deps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
318318
"itertools",
319319
"itoa",
320320
"jemalloc-sys",
321+
"jemallocator",
321322
"jobserver",
322323
"lazy_static",
323324
"leb128",

0 commit comments

Comments
 (0)