Skip to content

Commit 298dcd5

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#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 rust-lang#36963
2 parents 5f1fd68 + 94cb105 commit 298dcd5

38 files changed

+60
-462
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
@@ -296,12 +296,6 @@
296296
# Adding debuginfo makes them several times larger.
297297
#debuginfo-tools = false
298298

299-
# Whether or not jemalloc is built and enabled
300-
#use-jemalloc = true
301-
302-
# Whether or not jemalloc is built with its debug option set
303-
#debug-jemalloc = false
304-
305299
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
306300
#backtrace = true
307301

@@ -398,6 +392,10 @@
398392
# generally only set for releases
399393
#remap-debuginfo = false
400394

395+
# Link the compiler against `jemalloc`, where on Linux and OSX it should
396+
# override the default allocator for rustc and LLVM.
397+
#jemalloc = false
398+
401399
# =============================================================================
402400
# Options for specific targets
403401
#
@@ -437,10 +435,6 @@
437435
# not, you can specify an explicit file name for it.
438436
#llvm-filecheck = "/path/to/FileCheck"
439437

440-
# Path to the custom jemalloc static library to link into the standard library
441-
# by default. This is only used if jemalloc is still enabled above
442-
#jemalloc = "/path/to/jemalloc/libjemalloc_pic.a"
443-
444438
# If this target is for Android, this option will be required to specify where
445439
# the NDK for the target lives. This is used to find the C compiler to link and
446440
# 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"
@@ -784,6 +773,11 @@ dependencies = [
784773
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
785774
]
786775

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

992+
[[package]]
993+
name = "jemalloc-sys"
994+
version = "0.1.8"
995+
source = "registry+https://github.com/rust-lang/crates.io-index"
996+
dependencies = [
997+
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
998+
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
999+
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
1000+
]
1001+
9981002
[[package]]
9991003
name = "jobserver"
10001004
version = "0.1.11"
@@ -2180,6 +2184,7 @@ dependencies = [
21802184
"arena 0.0.0",
21812185
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
21822186
"graphviz 0.0.0",
2187+
"jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
21832188
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
21842189
"rustc 0.0.0",
21852190
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2679,7 +2684,6 @@ name = "std"
26792684
version = "0.0.0"
26802685
dependencies = [
26812686
"alloc 0.0.0",
2682-
"alloc_jemalloc 0.0.0",
26832687
"alloc_system 0.0.0",
26842688
"build_helper 0.1.0",
26852689
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3236,6 +3240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
32363240
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
32373241
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
32383242
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
3243+
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
32393244
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"
32403245
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
32413246
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
@@ -3258,6 +3263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
32583263
"checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053"
32593264
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
32603265
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
3266+
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
32613267
"checksum jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "60af5f849e1981434e4a31d3d782c4774ae9b434ce55b101a96ecfd09147e8be"
32623268
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
32633269
"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
@@ -712,11 +712,6 @@ def update_submodules(self):
712712
backends = self.get_toml('codegen-backends')
713713
if backends is None or not 'emscripten' in backends:
714714
continue
715-
if module.endswith("jemalloc"):
716-
if self.get_toml('use-jemalloc') == 'false':
717-
continue
718-
if self.get_toml('jemalloc'):
719-
continue
720715
if module.endswith("lld"):
721716
config = self.get_toml('lld')
722717
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
@@ -115,15 +115,14 @@ pub struct Config {
115115
pub hosts: Vec<Interned<String>>,
116116
pub targets: Vec<Interned<String>>,
117117
pub local_rebuild: bool,
118+
pub jemalloc: bool,
118119

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

124125
// libstd features
125-
pub debug_jemalloc: bool,
126-
pub use_jemalloc: bool,
127126
pub backtrace: bool, // support for RUST_BACKTRACE
128127
pub wasm_syscall: bool,
129128

@@ -165,7 +164,6 @@ pub struct Target {
165164
pub llvm_config: Option<PathBuf>,
166165
/// Some(path to FileCheck) if one was specified.
167166
pub llvm_filecheck: Option<PathBuf>,
168-
pub jemalloc: Option<PathBuf>,
169167
pub cc: Option<PathBuf>,
170168
pub cxx: Option<PathBuf>,
171169
pub ar: Option<PathBuf>,
@@ -262,7 +260,7 @@ struct Llvm {
262260
link_jobs: Option<u32>,
263261
link_shared: Option<bool>,
264262
version_suffix: Option<String>,
265-
clang_cl: Option<String>
263+
clang_cl: Option<String>,
266264
}
267265

268266
#[derive(Deserialize, Default, Clone)]
@@ -300,8 +298,6 @@ struct Rust {
300298
debuginfo_only_std: Option<bool>,
301299
debuginfo_tools: Option<bool>,
302300
experimental_parallel_queries: Option<bool>,
303-
debug_jemalloc: Option<bool>,
304-
use_jemalloc: Option<bool>,
305301
backtrace: Option<bool>,
306302
default_linker: Option<String>,
307303
channel: Option<String>,
@@ -327,6 +323,7 @@ struct Rust {
327323
backtrace_on_ice: Option<bool>,
328324
verify_llvm_ir: Option<bool>,
329325
remap_debuginfo: Option<bool>,
326+
jemalloc: Option<bool>,
330327
}
331328

332329
/// TOML representation of how each build target is configured.
@@ -335,7 +332,6 @@ struct Rust {
335332
struct TomlTarget {
336333
llvm_config: Option<String>,
337334
llvm_filecheck: Option<String>,
338-
jemalloc: Option<String>,
339335
cc: Option<String>,
340336
cxx: Option<String>,
341337
ar: Option<String>,
@@ -361,7 +357,6 @@ impl Config {
361357
config.llvm_enabled = true;
362358
config.llvm_optimize = true;
363359
config.llvm_version_check = true;
364-
config.use_jemalloc = true;
365360
config.backtrace = true;
366361
config.rust_optimize = true;
367362
config.rust_optimize_tests = true;
@@ -497,7 +492,6 @@ impl Config {
497492
let mut debuginfo_only_std = None;
498493
let mut debuginfo_tools = None;
499494
let mut debug = None;
500-
let mut debug_jemalloc = None;
501495
let mut debuginfo = None;
502496
let mut debug_assertions = None;
503497
let mut optimize = None;
@@ -539,12 +533,11 @@ impl Config {
539533
debuginfo_tools = rust.debuginfo_tools;
540534
optimize = rust.optimize;
541535
ignore_git = rust.ignore_git;
542-
debug_jemalloc = rust.debug_jemalloc;
543536
set(&mut config.rust_optimize_tests, rust.optimize_tests);
544537
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
545538
set(&mut config.codegen_tests, rust.codegen_tests);
546539
set(&mut config.rust_rpath, rust.rpath);
547-
set(&mut config.use_jemalloc, rust.use_jemalloc);
540+
set(&mut config.jemalloc, rust.jemalloc);
548541
set(&mut config.backtrace, rust.backtrace);
549542
set(&mut config.channel, rust.channel.clone());
550543
set(&mut config.rust_dist_src, rust.dist_src);
@@ -592,9 +585,6 @@ impl Config {
592585
if let Some(ref s) = cfg.llvm_filecheck {
593586
target.llvm_filecheck = Some(config.src.join(s));
594587
}
595-
if let Some(ref s) = cfg.jemalloc {
596-
target.jemalloc = Some(config.src.join(s));
597-
}
598588
if let Some(ref s) = cfg.android_ndk {
599589
target.ndk = Some(config.src.join(s));
600590
}
@@ -640,7 +630,6 @@ impl Config {
640630
config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false);
641631

642632
let default = debug == Some(true);
643-
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
644633
config.rust_debuginfo = debuginfo.unwrap_or(default);
645634
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
646635

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,13 +877,11 @@ 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
];
885883
let std_src_dirs_exclude = [
886884
"src/libcompiler_builtins/compiler-rt/test",
887-
"src/jemalloc/test/unit",
888885
];
889886

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

0 commit comments

Comments
 (0)