Skip to content

Commit b6e8f9d

Browse files
committed
Auto merge of #55238 - alexcrichton:rm-jemalloc, r=estebank
Remove the `alloc_jemalloc` crate This commit removes the `alloc_jemalloc` crate from the standard library and all related configuration. We will no longer be shipping this unstable crate. Rationale for this is provided on #36963 and the many linked issues, but I can inline rationale here if desired! We currently rely on jemalloc for increased perf in the Rust compiler, however. [This perf run shows](https://perf.rust-lang.org/compare.html?start=74ff7dcb1388e60a613cd6050bcd372a3cc4998b&end=7e7928dc0340d79b404e93f0c79eb4b946c1d669&stat=wall-time) that if we switch to glibc 2.23's allocator that it's slower than jemalloc across many benchmarks. [This perf run, however](https://perf.rust-lang.org/compare.html?start=22cc2ae8057d14e980b7c784e1eb2eee26b59e7d&end=10c95ccfa7a7adc12f4e608621ca29f9b98eed29), shows that if we use `jemalloc-sys` from crates.io then rustc actually gets faster across all benchmarks! (presumably because it has a more recent version of jemalloc than our submodule). As a result, it's expected that this doesn't regress any code (as it's just removing an unstable crate) and it should actually improve rustc performance because it updates jemalloc. Closes #36963
2 parents 757d6cc + 14c6835 commit b6e8f9d

Some content is hidden

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

41 files changed

+165
-473
lines changed

.gitmodules

+1-4
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
@@ -64,4 +61,4 @@
6461
path = src/tools/clang
6562
url = https://github.com/rust-lang-nursery/clang.git
6663
branch = rust-release-80-v1
67-
64+

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ matrix:
3030

3131
- env: >
3232
RUST_CHECK_TARGET=dist
33-
RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler --enable-lldb"
33+
RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler --enable-lldb --set rust.jemalloc"
3434
SRC=.
3535
DEPLOY_ALT=1
3636
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
@@ -53,7 +53,7 @@ matrix:
5353
# version that we're using, 8.2, cannot compile LLVM for OSX 10.7.
5454
- env: >
5555
RUST_CHECK_TARGET=check
56-
RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler"
56+
RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc"
5757
SRC=.
5858
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
5959
MACOSX_DEPLOYMENT_TARGET=10.8
@@ -67,7 +67,7 @@ matrix:
6767
6868
- env: >
6969
RUST_CHECK_TARGET=check
70-
RUST_CONFIGURE_ARGS=--build=i686-apple-darwin
70+
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --set rust.jemalloc"
7171
SRC=.
7272
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
7373
MACOSX_DEPLOYMENT_TARGET=10.8
@@ -87,7 +87,7 @@ matrix:
8787
# OSX 10.7 and `xcode7` is the latest Xcode able to compile LLVM for 10.7.
8888
- env: >
8989
RUST_CHECK_TARGET=dist
90-
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-full-tools --enable-profiler --enable-lldb"
90+
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-full-tools --enable-profiler --enable-lldb --set rust.jemalloc"
9191
SRC=.
9292
DEPLOY=1
9393
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
@@ -102,7 +102,7 @@ matrix:
102102
103103
- env: >
104104
RUST_CHECK_TARGET=dist
105-
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb"
105+
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc"
106106
SRC=.
107107
DEPLOY=1
108108
RUSTC_RETRY_LINKER_ON_SEGFAULT=1

config.toml.example

+4-10
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@
300300
# Adding debuginfo makes them several times larger.
301301
#debuginfo-tools = false
302302

303-
# Whether or not jemalloc is built and enabled
304-
#use-jemalloc = true
305-
306-
# Whether or not jemalloc is built with its debug option set
307-
#debug-jemalloc = false
308-
309303
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
310304
#backtrace = true
311305

@@ -402,6 +396,10 @@
402396
# generally only set for releases
403397
#remap-debuginfo = false
404398

399+
# Link the compiler against `jemalloc`, where on Linux and OSX it should
400+
# override the default allocator for rustc and LLVM.
401+
#jemalloc = false
402+
405403
# =============================================================================
406404
# Options for specific targets
407405
#
@@ -441,10 +439,6 @@
441439
# not, you can specify an explicit file name for it.
442440
#llvm-filecheck = "/path/to/FileCheck"
443441

444-
# Path to the custom jemalloc static library to link into the standard library
445-
# by default. This is only used if jemalloc is still enabled above
446-
#jemalloc = "/path/to/jemalloc/libjemalloc_pic.a"
447-
448442
# If this target is for Android, this option will be required to specify where
449443
# the NDK for the target lives. This is used to find the C compiler to link and
450444
# build native code.

src/Cargo.lock

+18-12
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ dependencies = [
1515
"rand 0.5.5 (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.25 (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"
@@ -785,6 +774,11 @@ dependencies = [
785774
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
786775
]
787776

777+
[[package]]
778+
name = "fs_extra"
779+
version = "1.1.0"
780+
source = "registry+https://github.com/rust-lang/crates.io-index"
781+
788782
[[package]]
789783
name = "fst"
790784
version = "0.3.0"
@@ -996,6 +990,16 @@ name = "itoa"
996990
version = "0.4.3"
997991
source = "registry+https://github.com/rust-lang/crates.io-index"
998992

993+
[[package]]
994+
name = "jemalloc-sys"
995+
version = "0.1.8"
996+
source = "registry+https://github.com/rust-lang/crates.io-index"
997+
dependencies = [
998+
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
999+
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1000+
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
1001+
]
1002+
9991003
[[package]]
10001004
name = "jobserver"
10011005
version = "0.1.11"
@@ -2181,6 +2185,7 @@ dependencies = [
21812185
"arena 0.0.0",
21822186
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
21832187
"graphviz 0.0.0",
2188+
"jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
21842189
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
21852190
"rustc 0.0.0",
21862191
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2680,7 +2685,6 @@ name = "std"
26802685
version = "0.0.0"
26812686
dependencies = [
26822687
"alloc 0.0.0",
2683-
"alloc_jemalloc 0.0.0",
26842688
"alloc_system 0.0.0",
26852689
"build_helper 0.1.0",
26862690
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3237,6 +3241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
32373241
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
32383242
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
32393243
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
3244+
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
32403245
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"
32413246
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
32423247
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
@@ -3259,6 +3264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
32593264
"checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053"
32603265
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
32613266
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
3267+
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
32623268
"checksum jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "60af5f849e1981434e4a31d3d782c4774ae9b434ce55b101a96ecfd09147e8be"
32633269
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
32643270
"checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c"

src/bootstrap/bootstrap.py

-5
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,6 @@ def update_submodules(self):
715715
backends = self.get_toml('codegen-backends')
716716
if backends is None or not 'emscripten' in backends:
717717
continue
718-
if module.endswith("jemalloc"):
719-
if self.get_toml('use-jemalloc') == 'false':
720-
continue
721-
if self.get_toml('jemalloc'):
722-
continue
723718
if module.endswith("lld"):
724719
config = self.get_toml('lld')
725720
if config is None or config == 'false':

src/bootstrap/compile.rs

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

172163
if compiler.stage != 0 && builder.config.sanitizers {
173164
// This variable is used by the sanitizer runtime crates, e.g.
@@ -188,11 +179,6 @@ pub fn std_cargo(builder: &Builder,
188179
.arg("--manifest-path")
189180
.arg(builder.src.join("src/libstd/Cargo.toml"));
190181

191-
if let Some(target) = builder.config.target_config.get(&target) {
192-
if let Some(ref jemalloc) = target.jemalloc {
193-
cargo.env("JEMALLOC_OVERRIDE", jemalloc);
194-
}
195-
}
196182
if target.contains("musl") {
197183
if let Some(p) = builder.musl_root(target) {
198184
cargo.env("MUSL_ROOT", p);

src/bootstrap/config.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,14 @@ pub struct Config {
116116
pub hosts: Vec<Interned<String>>,
117117
pub targets: Vec<Interned<String>>,
118118
pub local_rebuild: bool,
119+
pub jemalloc: bool,
119120

120121
// dist misc
121122
pub dist_sign_folder: Option<PathBuf>,
122123
pub dist_upload_addr: Option<String>,
123124
pub dist_gpg_password_file: Option<PathBuf>,
124125

125126
// libstd features
126-
pub debug_jemalloc: bool,
127-
pub use_jemalloc: bool,
128127
pub backtrace: bool, // support for RUST_BACKTRACE
129128
pub wasm_syscall: bool,
130129

@@ -166,7 +165,6 @@ pub struct Target {
166165
pub llvm_config: Option<PathBuf>,
167166
/// Some(path to FileCheck) if one was specified.
168167
pub llvm_filecheck: Option<PathBuf>,
169-
pub jemalloc: Option<PathBuf>,
170168
pub cc: Option<PathBuf>,
171169
pub cxx: Option<PathBuf>,
172170
pub ar: Option<PathBuf>,
@@ -263,7 +261,7 @@ struct Llvm {
263261
link_jobs: Option<u32>,
264262
link_shared: Option<bool>,
265263
version_suffix: Option<String>,
266-
clang_cl: Option<String>
264+
clang_cl: Option<String>,
267265
}
268266

269267
#[derive(Deserialize, Default, Clone)]
@@ -302,8 +300,6 @@ struct Rust {
302300
debuginfo_only_std: Option<bool>,
303301
debuginfo_tools: Option<bool>,
304302
experimental_parallel_queries: Option<bool>,
305-
debug_jemalloc: Option<bool>,
306-
use_jemalloc: Option<bool>,
307303
backtrace: Option<bool>,
308304
default_linker: Option<String>,
309305
channel: Option<String>,
@@ -329,6 +325,7 @@ struct Rust {
329325
backtrace_on_ice: Option<bool>,
330326
verify_llvm_ir: Option<bool>,
331327
remap_debuginfo: Option<bool>,
328+
jemalloc: Option<bool>,
332329
}
333330

334331
/// TOML representation of how each build target is configured.
@@ -337,7 +334,6 @@ struct Rust {
337334
struct TomlTarget {
338335
llvm_config: Option<String>,
339336
llvm_filecheck: Option<String>,
340-
jemalloc: Option<String>,
341337
cc: Option<String>,
342338
cxx: Option<String>,
343339
ar: Option<String>,
@@ -363,7 +359,6 @@ impl Config {
363359
config.llvm_enabled = true;
364360
config.llvm_optimize = true;
365361
config.llvm_version_check = true;
366-
config.use_jemalloc = true;
367362
config.backtrace = true;
368363
config.rust_optimize = true;
369364
config.rust_optimize_tests = true;
@@ -499,7 +494,6 @@ impl Config {
499494
let mut debuginfo_only_std = None;
500495
let mut debuginfo_tools = None;
501496
let mut debug = None;
502-
let mut debug_jemalloc = None;
503497
let mut debuginfo = None;
504498
let mut debug_assertions = None;
505499
let mut optimize = None;
@@ -541,12 +535,11 @@ impl Config {
541535
debuginfo_tools = rust.debuginfo_tools;
542536
optimize = rust.optimize;
543537
ignore_git = rust.ignore_git;
544-
debug_jemalloc = rust.debug_jemalloc;
545538
set(&mut config.rust_optimize_tests, rust.optimize_tests);
546539
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
547540
set(&mut config.codegen_tests, rust.codegen_tests);
548541
set(&mut config.rust_rpath, rust.rpath);
549-
set(&mut config.use_jemalloc, rust.use_jemalloc);
542+
set(&mut config.jemalloc, rust.jemalloc);
550543
set(&mut config.backtrace, rust.backtrace);
551544
set(&mut config.channel, rust.channel.clone());
552545
set(&mut config.rust_dist_src, rust.dist_src);
@@ -596,9 +589,6 @@ impl Config {
596589
if let Some(ref s) = cfg.llvm_filecheck {
597590
target.llvm_filecheck = Some(config.src.join(s));
598591
}
599-
if let Some(ref s) = cfg.jemalloc {
600-
target.jemalloc = Some(config.src.join(s));
601-
}
602592
if let Some(ref s) = cfg.android_ndk {
603593
target.ndk = Some(config.src.join(s));
604594
}
@@ -644,7 +634,6 @@ impl Config {
644634
config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false);
645635

646636
let default = debug == Some(true);
647-
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
648637
config.rust_debuginfo = debuginfo.unwrap_or(default);
649638
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
650639

src/bootstrap/configure.py

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

8887
v("prefix", "install.prefix", "set installation prefix")
@@ -99,7 +98,6 @@ def v(*args):
9998
v("llvm-config", None, "set path to llvm-config")
10099
v("llvm-filecheck", None, "set path to LLVM's FileCheck utility")
101100
v("python", "build.python", "set path to python")
102-
v("jemalloc-root", None, "set directory where libjemalloc_pic.a is located")
103101
v("android-cross-path", "target.arm-linux-androideabi.android-ndk",
104102
"Android NDK standalone path (deprecated)")
105103
v("i686-linux-android-ndk", "target.i686-linux-android.android-ndk",
@@ -148,7 +146,6 @@ def v(*args):
148146
# Many of these are saved below during the "writing configuration" step
149147
# (others are conditionally saved).
150148
o("manage-submodules", "build.submodules", "let the build manage the git submodules")
151-
o("jemalloc", "rust.use-jemalloc", "build liballoc with jemalloc")
152149
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two")
153150
o("extended", "build.extended", "build an extended rust tool set")
154151

@@ -330,8 +327,6 @@ def set(key, value):
330327
set('target.{}.llvm-config'.format(build()), value)
331328
elif option.name == 'llvm-filecheck':
332329
set('target.{}.llvm-filecheck'.format(build()), value)
333-
elif option.name == 'jemalloc-root':
334-
set('target.{}.jemalloc'.format(build()), value + '/libjemalloc_pic.a')
335330
elif option.name == 'tools':
336331
set('build.tools', value.split(','))
337332
elif option.name == 'host':

src/bootstrap/dist.rs

-3
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ impl Step for Src {
859859
"src/build_helper",
860860
"src/dlmalloc",
861861
"src/liballoc",
862-
"src/liballoc_jemalloc",
863862
"src/liballoc_system",
864863
"src/libbacktrace",
865864
"src/libcompiler_builtins",
@@ -878,14 +877,12 @@ impl Step for Src {
878877
"src/rustc/dlmalloc_shim",
879878
"src/libtest",
880879
"src/libterm",
881-
"src/jemalloc",
882880
"src/libprofiler_builtins",
883881
"src/stdsimd",
884882
"src/libproc_macro",
885883
];
886884
let std_src_dirs_exclude = [
887885
"src/libcompiler_builtins/compiler-rt/test",
888-
"src/jemalloc/test/unit",
889886
];
890887

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

0 commit comments

Comments
 (0)