mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
#5244 Pass `JEMALLOC_SYS_WITH_LG_PAGE=16` env to aarch64 cross-compilation to support systems with up to 64-KiB page sizes. This is backwards-compatible for the current (most usual) 4-KiB systems.
This commit is contained in:
committed by
GitHub
parent
66c6552e8c
commit
d297d08c6b
@@ -1,4 +1,3 @@
|
||||
[env]
|
||||
# Set the number of arenas to 16 when using jemalloc.
|
||||
JEMALLOC_SYS_WITH_MALLOC_CONF = "abort_conf:true,narenas:16"
|
||||
|
||||
|
||||
11
Cross.toml
11
Cross.toml
@@ -3,3 +3,14 @@ pre-build = ["apt-get install -y cmake clang-5.0"]
|
||||
|
||||
[target.aarch64-unknown-linux-gnu]
|
||||
pre-build = ["apt-get install -y cmake clang-5.0"]
|
||||
|
||||
# Allow setting page size limits for jemalloc at build time:
|
||||
# For certain architectures (like aarch64), we must compile
|
||||
# jemalloc with support for large page sizes, otherwise the host's
|
||||
# system page size will be used, which may not work on the target systems.
|
||||
# JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to support up to 64-KiB
|
||||
# pages. See: https://github.com/sigp/lighthouse/issues/5244
|
||||
[build.env]
|
||||
passthrough = [
|
||||
"JEMALLOC_SYS_WITH_LG_PAGE",
|
||||
]
|
||||
|
||||
10
Makefile
10
Makefile
@@ -63,12 +63,18 @@ install-lcli:
|
||||
build-x86_64:
|
||||
cross build --bin lighthouse --target x86_64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked
|
||||
build-aarch64:
|
||||
cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked
|
||||
# JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to support up to 64-KiB
|
||||
# pages, which are commonly used by aarch64 systems.
|
||||
# See: https://github.com/sigp/lighthouse/issues/5244
|
||||
JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked
|
||||
|
||||
build-lcli-x86_64:
|
||||
cross build --bin lcli --target x86_64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked
|
||||
build-lcli-aarch64:
|
||||
cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked
|
||||
# JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to support up to 64-KiB
|
||||
# pages, which are commonly used by aarch64 systems.
|
||||
# See: https://github.com/sigp/lighthouse/issues/5244
|
||||
JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked
|
||||
|
||||
# Create a `.tar.gz` containing a binary for a specific target.
|
||||
define tarball_release_binary
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! B) `_RJEM_MALLOC_CONF` at runtime.
|
||||
use metrics::{set_gauge, try_create_int_gauge, IntGauge};
|
||||
use std::sync::LazyLock;
|
||||
use tikv_jemalloc_ctl::{arenas, epoch, stats, Error};
|
||||
use tikv_jemalloc_ctl::{arenas, epoch, stats, Access, AsName, Error};
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||
@@ -52,3 +52,18 @@ pub fn scrape_jemalloc_metrics_fallible() -> Result<(), Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn page_size() -> Result<usize, Error> {
|
||||
// Full list of keys: https://jemalloc.net/jemalloc.3.html
|
||||
"arenas.page\0".name().read()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn page_size_ok() {
|
||||
assert!(page_size().is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
not(target_env = "musl"),
|
||||
not(feature = "jemalloc")
|
||||
))]
|
||||
mod glibc;
|
||||
pub mod glibc;
|
||||
|
||||
#[cfg(feature = "jemalloc")]
|
||||
mod jemalloc;
|
||||
pub mod jemalloc;
|
||||
|
||||
pub use interface::*;
|
||||
|
||||
|
||||
@@ -66,11 +66,15 @@ fn bls_hardware_acceleration() -> bool {
|
||||
return std::arch::is_aarch64_feature_detected!("neon");
|
||||
}
|
||||
|
||||
fn allocator_name() -> &'static str {
|
||||
if cfg!(target_os = "windows") {
|
||||
"system"
|
||||
} else {
|
||||
"jemalloc"
|
||||
fn allocator_name() -> String {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
"system".to_string()
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
match malloc_utils::jemalloc::page_size() {
|
||||
Ok(page_size) => format!("jemalloc ({}K)", page_size / 1024),
|
||||
Err(e) => format!("jemalloc (error: {e:?})"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user