Description
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=16
only 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 :) )