Skip to content

Commit fd00e12

Browse files
Add disable_cache_oblivious feature (#51)
When this feature is used, it will build Jemalloc with `--disable-cache-oblivious`. The feature is disabled by default. Signed-off-by: Carlos Galdino <[email protected]>
1 parent 0cc7b0e commit fd00e12

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

jemalloc-sys/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ background_threads = [ "background_threads_runtime_support" ]
4040
stats = []
4141
unprefixed_malloc_on_supported_platforms = []
4242
disable_initial_exec_tls = []
43+
disable_cache_oblivious = []
4344

4445
[package.metadata.docs.rs]
4546
rustdoc-args = [ "--cfg", "jemallocator_docs" ]

jemalloc-sys/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ This crate provides following cargo feature flags:
8484
the error `yourlib.so: cannot allocate memory in static TLS block`, you'll
8585
likely want to enable this.
8686

87+
* `disable_cache_oblivious` (disabled by default): when enabled, jemalloc is
88+
built with the `--disable-cache-oblivious` option. In that case, all large
89+
allocations are page-aligned as an implementation artifact. It may severely
90+
harm CPU cache utilization. However, the cache-oblivious layout has a cost of
91+
one extra page per large allocation which can be unfeasible for certain
92+
applications.
93+
8794
### Environment variables
8895

8996
`jemalloc` options taking values are passed via environment variables using the

jemalloc-sys/build.rs

+5
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ fn main() {
262262
cmd.arg("--disable-initial-exec-tls");
263263
}
264264

265+
if env::var("CARGO_FEATURE_DISABLE_CACHE_OBLIVIOUS").is_ok() {
266+
info!("CARGO_FEATURE_DISABLE_CACHE_OBLIVIOUS set");
267+
cmd.arg("--disable-cache-oblivious");
268+
}
269+
265270
cmd.arg(format!("--host={}", gnu_target(&target)));
266271
cmd.arg(format!("--build={}", gnu_target(&host)));
267272
cmd.arg(format!("--prefix={}", out_dir.display()));

0 commit comments

Comments
 (0)