You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently, in a project using tikv/jemallocator, I've tried to support AArch64 systems with 64kb page size (specifically these were Ubuntu largemem). I had to increase lg-page because jemalloc complained if the system page size was larger than lg-page.
This can be controlled with the JEMALLOC_SYS_WITH_LG_PAGE env var this crate parses, but it turned out not very convenient for me. I wanted to enable lg-page=16only for AArch64, and couldn't find a way to do so nicely within the cargo ecosystem. I tried:
[env] section in .cargo/config.toml - can not be specified per-arch
Tried to emit the env var in the build script of the crate that has tikv/jemallocator as dependency (basically like rustc did here, but that's not a standard build script, and in standard build scripts, a la cargo:rustc-env=, the env vars are not inherited to dependency crates).
as I wanted this to remain within cargo I ended up forking the repository and hardcoding a check for AArch64 which enables this.
The alternative I see used online is to pass the env var externally to cargo (i.e, JEMALLOC_SYS_WITH_LG_PAGE=16 cargo build -p my_crate...).
Can we add a knob to this project that'll allow controlling this within cargo boundaries? I don't know of any way to control a numeric parameter of a dependency crate. The 2 potential solutions I have in mind are specific to lg-page=16 which helps with the increasing popularity of 64kb-page-size AArch64 machines:
a feature 64kb_page_size_on_aarch64 that does what I described if enabled
a feature that always sets lg-page=16, and as dependencies can be pulled conditionally on arch ([target.'cfg(target_arch = "aarch64")'.dependencies]), this gives the user sufficient control over it in cargo-level.
I'm happy to implement either of these (or any other idea that you may have that'll allow me to enable lg-page=16 only on AArch64 via cargo :) )
Reacted by arilou, Mikhail Domanoski and Rene Leonhardt
Activity
goffrie commentedon Sep 17, 2025
For what it's worth, "new upstream" (i.e. facebook/jemalloc) has changed the default aarch64-linux page size to 64KiB: meta/jemalloc#34
BusyJay commentedon Sep 18, 2025
With #91 you should be able to set environment variable for some target only.
Jongy commentedon Sep 30, 2025
Thanks @BusyJay ! Using
AARCH64_UNKNOWN_LINUX_GNU_JEMALLOC_SYS_WITH_LG_PAGE = "16"seems to do the trick.build: pin jemalloc's page size to 4 KiB on aarch64 Linux (#39549)