Skip to content

Commit 91eac4d

Browse files
committed
Auto merge of #52020 - SimonSapin:no-jemalloc, r=<try>
[Do not merge yet] Remove alloc_jemalloc, switch the default global allocator to System Fixes #36963 **Do not merge** yet. This PR by itself is likely to regress rustc performance. The purpose of opening it now is to measure by how much. We’ll likely want to figure out #51038 and land them around the same time.
2 parents 860d169 + 54fa990 commit 91eac4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+24
-613
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
path = src/llvm
33
url = https://github.com/rust-lang/llvm.git
44
branch = master
5-
[submodule "src/jemalloc"]
6-
path = src/jemalloc
7-
url = https://github.com/rust-lang/jemalloc.git
85
[submodule "src/rust-installer"]
96
path = src/tools/rust-installer
107
url = https://github.com/rust-lang/rust-installer.git

COPYRIGHT

-32
Original file line numberDiff line numberDiff line change
@@ -229,35 +229,3 @@ their own copyright notices and license terms:
229229
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
230230
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
231231
OF SUCH DAMAGE. */
232-
233-
* jemalloc, under src/jemalloc:
234-
235-
Copyright (C) 2002-2014 Jason Evans
236-
<[email protected]>. All rights reserved.
237-
Copyright (C) 2007-2012 Mozilla Foundation.
238-
All rights reserved.
239-
Copyright (C) 2009-2014 Facebook, Inc.
240-
All rights reserved.
241-
242-
Redistribution and use in source and binary forms, with or without
243-
modification, are permitted provided that the following conditions are met:
244-
1. Redistributions of source code must retain the above copyright notice(s),
245-
this list of conditions and the following disclaimer.
246-
2. Redistributions in binary form must reproduce the above copyright notice(s),
247-
this list of conditions and the following disclaimer in the documentation
248-
and/or other materials provided with the distribution.
249-
250-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S)
251-
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
252-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
253-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
254-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S)
255-
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
256-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
257-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
258-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
259-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
260-
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
261-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
262-
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
263-
OF SUCH DAMAGE.

config.toml.example

-10
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,6 @@
270270
# Adding debuginfo makes them several times larger.
271271
#debuginfo-tools = false
272272

273-
# Whether or not jemalloc is built and enabled
274-
#use-jemalloc = true
275-
276-
# Whether or not jemalloc is built with its debug option set
277-
#debug-jemalloc = false
278-
279273
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
280274
#backtrace = true
281275

@@ -391,10 +385,6 @@
391385
# target.
392386
#llvm-config = "../path/to/llvm/root/bin/llvm-config"
393387

394-
# Path to the custom jemalloc static library to link into the standard library
395-
# by default. This is only used if jemalloc is still enabled above
396-
#jemalloc = "/path/to/jemalloc/libjemalloc_pic.a"
397-
398388
# If this target is for Android, this option will be required to specify where
399389
# the NDK for the target lives. This is used to find the C compiler to link and
400390
# build native code.

src/Cargo.lock

-12
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ dependencies = [
1515
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
1616
]
1717

18-
[[package]]
19-
name = "alloc_jemalloc"
20-
version = "0.0.0"
21-
dependencies = [
22-
"build_helper 0.1.0",
23-
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
24-
"compiler_builtins 0.0.0",
25-
"core 0.0.0",
26-
"libc 0.0.0",
27-
]
28-
2918
[[package]]
3019
name = "alloc_system"
3120
version = "0.0.0"
@@ -2638,7 +2627,6 @@ name = "std"
26382627
version = "0.0.0"
26392628
dependencies = [
26402629
"alloc 0.0.0",
2641-
"alloc_jemalloc 0.0.0",
26422630
"alloc_system 0.0.0",
26432631
"build_helper 0.1.0",
26442632
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",

src/bootstrap/bootstrap.py

-5
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,6 @@ def update_submodules(self):
696696
backends = self.get_toml('codegen-backends')
697697
if backends is None or not 'emscripten' in backends:
698698
continue
699-
if module.endswith("jemalloc"):
700-
if self.get_toml('use-jemalloc') == 'false':
701-
continue
702-
if self.get_toml('jemalloc'):
703-
continue
704699
if module.endswith("lld"):
705700
config = self.get_toml('lld')
706701
if config is None or config == 'false':

src/bootstrap/compile.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,7 @@ pub fn std_cargo(builder: &Builder,
163163
.arg("--manifest-path")
164164
.arg(builder.src.join("src/rustc/compiler_builtins_shim/Cargo.toml"));
165165
} else {
166-
let mut features = builder.std_features();
167-
168-
// When doing a local rebuild we tell cargo that we're stage1 rather than
169-
// stage0. This works fine if the local rust and being-built rust have the
170-
// same view of what the default allocator is, but fails otherwise. Since
171-
// we don't have a way to express an allocator preference yet, work
172-
// around the issue in the case of a local rebuild with jemalloc disabled.
173-
if compiler.stage == 0 && builder.local_rebuild && !builder.config.use_jemalloc {
174-
features.push_str(" force_alloc_system");
175-
}
166+
let features = builder.std_features();
176167

177168
if compiler.stage != 0 && builder.config.sanitizers {
178169
// This variable is used by the sanitizer runtime crates, e.g.
@@ -193,11 +184,6 @@ pub fn std_cargo(builder: &Builder,
193184
.arg("--manifest-path")
194185
.arg(builder.src.join("src/libstd/Cargo.toml"));
195186

196-
if let Some(target) = builder.config.target_config.get(&target) {
197-
if let Some(ref jemalloc) = target.jemalloc {
198-
cargo.env("JEMALLOC_OVERRIDE", jemalloc);
199-
}
200-
}
201187
if target.contains("musl") {
202188
if let Some(p) = builder.musl_root(target) {
203189
cargo.env("MUSL_ROOT", p);

src/bootstrap/config.rs

-14
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ pub struct Config {
117117
pub dist_gpg_password_file: Option<PathBuf>,
118118

119119
// libstd features
120-
pub debug_jemalloc: bool,
121-
pub use_jemalloc: bool,
122120
pub backtrace: bool, // support for RUST_BACKTRACE
123121
pub wasm_syscall: bool,
124122

@@ -157,7 +155,6 @@ pub struct Config {
157155
pub struct Target {
158156
/// Some(path to llvm-config) if using an external LLVM.
159157
pub llvm_config: Option<PathBuf>,
160-
pub jemalloc: Option<PathBuf>,
161158
pub cc: Option<PathBuf>,
162159
pub cxx: Option<PathBuf>,
163160
pub ar: Option<PathBuf>,
@@ -288,8 +285,6 @@ struct Rust {
288285
debuginfo_only_std: Option<bool>,
289286
debuginfo_tools: Option<bool>,
290287
experimental_parallel_queries: Option<bool>,
291-
debug_jemalloc: Option<bool>,
292-
use_jemalloc: Option<bool>,
293288
backtrace: Option<bool>,
294289
default_linker: Option<String>,
295290
channel: Option<String>,
@@ -319,7 +314,6 @@ struct Rust {
319314
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
320315
struct TomlTarget {
321316
llvm_config: Option<String>,
322-
jemalloc: Option<String>,
323317
cc: Option<String>,
324318
cxx: Option<String>,
325319
ar: Option<String>,
@@ -344,7 +338,6 @@ impl Config {
344338
config.llvm_enabled = true;
345339
config.llvm_optimize = true;
346340
config.llvm_version_check = true;
347-
config.use_jemalloc = true;
348341
config.backtrace = true;
349342
config.rust_optimize = true;
350343
config.rust_optimize_tests = true;
@@ -479,7 +472,6 @@ impl Config {
479472
let mut debuginfo_only_std = None;
480473
let mut debuginfo_tools = None;
481474
let mut debug = None;
482-
let mut debug_jemalloc = None;
483475
let mut debuginfo = None;
484476
let mut debug_assertions = None;
485477
let mut optimize = None;
@@ -519,12 +511,10 @@ impl Config {
519511
debuginfo_tools = rust.debuginfo_tools;
520512
optimize = rust.optimize;
521513
ignore_git = rust.ignore_git;
522-
debug_jemalloc = rust.debug_jemalloc;
523514
set(&mut config.rust_optimize_tests, rust.optimize_tests);
524515
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
525516
set(&mut config.codegen_tests, rust.codegen_tests);
526517
set(&mut config.rust_rpath, rust.rpath);
527-
set(&mut config.use_jemalloc, rust.use_jemalloc);
528518
set(&mut config.backtrace, rust.backtrace);
529519
set(&mut config.channel, rust.channel.clone());
530520
set(&mut config.rust_dist_src, rust.dist_src);
@@ -566,9 +556,6 @@ impl Config {
566556
if let Some(ref s) = cfg.llvm_config {
567557
target.llvm_config = Some(config.src.join(s));
568558
}
569-
if let Some(ref s) = cfg.jemalloc {
570-
target.jemalloc = Some(config.src.join(s));
571-
}
572559
if let Some(ref s) = cfg.android_ndk {
573560
target.ndk = Some(config.src.join(s));
574561
}
@@ -609,7 +596,6 @@ impl Config {
609596
config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false);
610597

611598
let default = debug == Some(true);
612-
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
613599
config.rust_debuginfo = debuginfo.unwrap_or(default);
614600
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
615601
config.rust_optimize = optimize.unwrap_or(!default);

src/bootstrap/configure.py

-5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def v(*args):
8080
o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata")
8181
o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information")
8282
o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information")
83-
o("debug-jemalloc", "rust.debug-jemalloc", "build jemalloc with --enable-debug --enable-fill")
8483
v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file")
8584

8685
v("prefix", "install.prefix", "set installation prefix")
@@ -95,7 +94,6 @@ def v(*args):
9594

9695
v("llvm-root", None, "set LLVM root")
9796
v("python", "build.python", "set path to python")
98-
v("jemalloc-root", None, "set directory where libjemalloc_pic.a is located")
9997
v("android-cross-path", "target.arm-linux-androideabi.android-ndk",
10098
"Android NDK standalone path (deprecated)")
10199
v("i686-linux-android-ndk", "target.i686-linux-android.android-ndk",
@@ -144,7 +142,6 @@ def v(*args):
144142
# Many of these are saved below during the "writing configuration" step
145143
# (others are conditionally saved).
146144
o("manage-submodules", "build.submodules", "let the build manage the git submodules")
147-
o("jemalloc", "rust.use-jemalloc", "build liballoc with jemalloc")
148145
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two")
149146
o("extended", "build.extended", "build an extended rust tool set")
150147

@@ -322,8 +319,6 @@ def set(key, value):
322319
set('build.cargo', value + '/bin/cargo')
323320
elif option.name == 'llvm-root':
324321
set('target.{}.llvm-config'.format(build()), value + '/bin/llvm-config')
325-
elif option.name == 'jemalloc-root':
326-
set('target.{}.jemalloc'.format(build()), value + '/libjemalloc_pic.a')
327322
elif option.name == 'tools':
328323
set('build.tools', value.split(','))
329324
elif option.name == 'host':

src/bootstrap/dist.rs

-3
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ impl Step for Src {
834834
"src/build_helper",
835835
"src/dlmalloc",
836836
"src/liballoc",
837-
"src/liballoc_jemalloc",
838837
"src/liballoc_system",
839838
"src/libbacktrace",
840839
"src/libcompiler_builtins",
@@ -854,13 +853,11 @@ impl Step for Src {
854853
"src/rustc/dlmalloc_shim",
855854
"src/libtest",
856855
"src/libterm",
857-
"src/jemalloc",
858856
"src/libprofiler_builtins",
859857
"src/stdsimd",
860858
];
861859
let std_src_dirs_exclude = [
862860
"src/libcompiler_builtins/compiler-rt/test",
863-
"src/jemalloc/test/unit",
864861
];
865862

866863
copy_src_dirs(builder, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);

src/bootstrap/lib.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,6 @@ impl Build {
498498
fn std_features(&self) -> String {
499499
let mut features = "panic-unwind".to_string();
500500

501-
if self.config.debug_jemalloc {
502-
features.push_str(" debug-jemalloc");
503-
}
504-
if self.config.use_jemalloc {
505-
features.push_str(" jemalloc");
506-
}
507501
if self.config.backtrace {
508502
features.push_str(" backtrace");
509503
}
@@ -518,11 +512,7 @@ impl Build {
518512

519513
/// Get the space-separated set of activated features for the compiler.
520514
fn rustc_features(&self) -> String {
521-
let mut features = String::new();
522-
if self.config.use_jemalloc {
523-
features.push_str(" jemalloc");
524-
}
525-
features
515+
String::new()
526516
}
527517

528518
/// Component directory that Cargo will produce output into (e.g.
@@ -732,7 +722,7 @@ impl Build {
732722
// If we're compiling on macOS then we add a few unconditional flags
733723
// indicating that we want libc++ (more filled out than libstdc++) and
734724
// we want to compile for 10.7. This way we can ensure that
735-
// LLVM/jemalloc/etc are all properly compiled.
725+
// LLVM/etc are all properly compiled.
736726
if target.contains("apple-darwin") {
737727
base.push("-stdlib=libc++".into());
738728
}

src/bootstrap/sanity.rs

-6
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@ pub fn check(build: &mut Build) {
152152
if !build.config.dry_run {
153153
cmd_finder.must_have(build.cxx(*host).unwrap());
154154
}
155-
156-
// The msvc hosts don't use jemalloc, turn it off globally to
157-
// avoid packaging the dummy liballoc_jemalloc on that platform.
158-
if host.contains("msvc") {
159-
build.config.use_jemalloc = false;
160-
}
161155
}
162156

163157
// Externally configured LLVM requires FileCheck to exist

src/bootstrap/test.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,7 @@ impl Step for CrateNotDefault {
14661466
type Output = ();
14671467

14681468
fn should_run(run: ShouldRun) -> ShouldRun {
1469-
run.path("src/liballoc_jemalloc")
1470-
.path("src/librustc_asan")
1469+
run.path("src/librustc_asan")
14711470
.path("src/librustc_lsan")
14721471
.path("src/librustc_msan")
14731472
.path("src/librustc_tsan")
@@ -1484,7 +1483,6 @@ impl Step for CrateNotDefault {
14841483
target: run.target,
14851484
test_kind,
14861485
krate: match run.path {
1487-
_ if run.path.ends_with("src/liballoc_jemalloc") => "alloc_jemalloc",
14881486
_ if run.path.ends_with("src/librustc_asan") => "rustc_asan",
14891487
_ if run.path.ends_with("src/librustc_lsan") => "rustc_lsan",
14901488
_ if run.path.ends_with("src/librustc_msan") => "rustc_msan",
@@ -1523,7 +1521,6 @@ impl Step for Crate {
15231521
run = run.krate("test");
15241522
for krate in run.builder.in_tree_crates("std") {
15251523
if krate.is_local(&run.builder)
1526-
&& !krate.name.contains("jemalloc")
15271524
&& !(krate.name.starts_with("rustc_") && krate.name.ends_with("san"))
15281525
&& krate.name != "dlmalloc"
15291526
{

src/ci/docker/disabled/dist-x86_64-haiku/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ RUN sh /scripts/sccache.sh
4242
ENV HOST=x86_64-unknown-haiku
4343
ENV TARGET=target.$HOST
4444

45-
ENV RUST_CONFIGURE_ARGS --disable-jemalloc \
45+
ENV RUST_CONFIGURE_ARGS \
4646
--set=$TARGET.cc=x86_64-unknown-haiku-gcc \
4747
--set=$TARGET.cxx=x86_64-unknown-haiku-g++ \
4848
--set=$TARGET.llvm-config=/bin/llvm-config-haiku

src/jemalloc

-1
This file was deleted.

src/liballoc/tests/heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::alloc::{Global, Alloc, Layout};
1414
/// https://github.com/rust-lang/rust/issues/45955
1515
///
1616
/// Note that `#[global_allocator]` is not used,
17-
/// so `liballoc_jemalloc` is linked (on some platforms).
17+
/// so `System` and `Global` might be backed by different allocators.
1818
#[test]
1919
fn alloc_system_overaligned_request() {
2020
check_overalign_requests(System)

src/liballoc_jemalloc/Cargo.toml

-24
This file was deleted.

0 commit comments

Comments
 (0)