mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 11:22:56 +00:00
Switch allocator to jemalloc (#3697)
Squashed commit of the following: commit974b3359f8Merge:ac205b7ba480309fb9Author: Michael Sproul <michael@sigmaprime.io> Date: Wed Jan 18 10:01:26 2023 +1100 Merge remote-tracking branch 'origin/unstable' into jemalloc commit480309fb96Author: aliask <aliask@gmail.com> Date: Tue Jan 17 05:13:49 2023 +0000 Fix some dead links in markdown files (#3885) ## Issue Addressed No issue has been raised for these broken links. ## Proposed Changes Update links with the new URLs for the same document. ## Additional Info ~The link for the [Lighthouse Development Updates](https://eepurl.com/dh9Lvb/) mailing list is also broken, but I can't find the correct link.~ Co-authored-by: Paul Hauner <paul@paulhauner.com> commitb4d9fc03eeAuthor: GeemoCandama <geemo@tutanota.com> Date: Tue Jan 17 05:13:48 2023 +0000 add logging for starting request and receiving block (#3858) ## Issue Addressed #3853 ## Proposed Changes Added `INFO` level logs for requesting and receiving the unsigned block. ## Additional Info Logging for successfully publishing the signed block is already there. And seemingly there is a log for when "We realize we are going to produce a block" in the `start_update_service`: `info!(log, "Block production service started"); `. Is there anywhere else you'd like to see logging around this event? Co-authored-by: GeemoCandama <104614073+GeemoCandama@users.noreply.github.com> commit9a970ce3a2Author: David Theodore <prodigalsonsolutions@gmail.com> Date: Tue Jan 17 05:13:47 2023 +0000 add better err reporting UnableToOpenVotingKeystore (#3781) ## Issue Addressed #3780 ## Proposed Changes Add error reporting that notifies the node operator that the `voting_keystore_path` in their `validator_definitions.yml` file may be incorrect. ## Additional Info There is more info in issue #3780 Co-authored-by: Paul Hauner <paul@paulhauner.com> commitac205b7babMerge:93457d85bbf533c8e4Author: Michael Sproul <michael@sigmaprime.io> Date: Fri Nov 25 16:32:33 2022 +1100 Merge remote-tracking branch 'origin/unstable' into jemalloc commit93457d85b7Author: Michael Sproul <michael@sigmaprime.io> Date: Wed Nov 9 11:53:59 2022 +1100 Fix cargo-udeps commit6c42aef1b5Author: Michael Sproul <micsproul@gmail.com> Date: Tue Nov 8 19:12:19 2022 +1100 Fixups commitf14b87bb88Author: Michael Sproul <michael@sigmaprime.io> Date: Tue Nov 8 16:28:16 2022 +1100 Update docs commit5005dc3b65Author: Michael Sproul <michael@sigmaprime.io> Date: Tue Nov 8 16:22:42 2022 +1100 Fix lcli commita082ba5904Author: Michael Sproul <michael@sigmaprime.io> Date: Tue Nov 8 16:17:10 2022 +1100 Remove check-consensus commit81441e9ceaAuthor: Michael Sproul <micsproul@gmail.com> Date: Tue Nov 8 15:28:11 2022 +1100 Disable jemalloc on Windows commit41eac5d0c1Author: Michael Sproul <micsproul@gmail.com> Date: Tue Nov 8 13:46:17 2022 +1100 Compatibility with macOS commit69ecba7876Author: Michael Sproul <michael@sigmaprime.io> Date: Mon Nov 7 18:48:31 2022 +1100 Add jemalloc support
This commit is contained in:
@@ -7,6 +7,46 @@
|
||||
//!
|
||||
//! A) `JEMALLOC_SYS_WITH_MALLOC_CONF` at compile-time.
|
||||
//! B) `_RJEM_MALLOC_CONF` at runtime.
|
||||
use jemalloc_ctl::{arenas, epoch, stats, Error};
|
||||
use lazy_static::lazy_static;
|
||||
use lighthouse_metrics::{set_gauge, try_create_int_gauge, IntGauge};
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
// Metrics for jemalloc.
|
||||
lazy_static! {
|
||||
pub static ref NUM_ARENAS: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_num_arenas", "The number of arenas in use");
|
||||
pub static ref BYTES_ALLOCATED: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_bytes_allocated", "Equivalent to stats.allocated");
|
||||
pub static ref BYTES_ACTIVE: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_bytes_active", "Equivalent to stats.active");
|
||||
pub static ref BYTES_MAPPED: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_bytes_mapped", "Equivalent to stats.mapped");
|
||||
pub static ref BYTES_METADATA: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_bytes_metadata", "Equivalent to stats.metadata");
|
||||
pub static ref BYTES_RESIDENT: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_bytes_resident", "Equivalent to stats.resident");
|
||||
pub static ref BYTES_RETAINED: lighthouse_metrics::Result<IntGauge> =
|
||||
try_create_int_gauge("jemalloc_bytes_retained", "Equivalent to stats.retained");
|
||||
}
|
||||
|
||||
pub fn scrape_jemalloc_metrics() {
|
||||
scrape_jemalloc_metrics_fallible().unwrap()
|
||||
}
|
||||
|
||||
pub fn scrape_jemalloc_metrics_fallible() -> Result<(), Error> {
|
||||
// Advance the epoch so that the underlying statistics are updated.
|
||||
epoch::advance()?;
|
||||
|
||||
set_gauge(&NUM_ARENAS, arenas::narenas::read()? as i64);
|
||||
set_gauge(&BYTES_ALLOCATED, stats::allocated::read()? as i64);
|
||||
set_gauge(&BYTES_ACTIVE, stats::active::read()? as i64);
|
||||
set_gauge(&BYTES_MAPPED, stats::mapped::read()? as i64);
|
||||
set_gauge(&BYTES_METADATA, stats::metadata::read()? as i64);
|
||||
set_gauge(&BYTES_RESIDENT, stats::resident::read()? as i64);
|
||||
set_gauge(&BYTES_RETAINED, stats::retained::read()? as i64);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
#[cfg(all(
|
||||
target_os = "linux",
|
||||
not(any(target_env = "musl", feature = "jemalloc"))
|
||||
not(target_env = "musl"),
|
||||
not(feature = "jemalloc")
|
||||
))]
|
||||
mod glibc;
|
||||
|
||||
@@ -37,14 +38,28 @@ pub use interface::*;
|
||||
|
||||
#[cfg(all(
|
||||
target_os = "linux",
|
||||
not(any(target_env = "musl", feature = "jemalloc"))
|
||||
not(target_env = "musl"),
|
||||
not(feature = "jemalloc")
|
||||
))]
|
||||
mod interface {
|
||||
pub use crate::glibc::configure_glibc_malloc as configure_memory_allocator;
|
||||
pub use crate::glibc::scrape_mallinfo_metrics as scrape_allocator_metrics;
|
||||
}
|
||||
|
||||
#[cfg(any(not(target_os = "linux"), target_env = "musl", feature = "jemalloc"))]
|
||||
#[cfg(feature = "jemalloc")]
|
||||
mod interface {
|
||||
#[allow(dead_code)]
|
||||
pub fn configure_memory_allocator() -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub use crate::jemalloc::scrape_jemalloc_metrics as scrape_allocator_metrics;
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(not(target_os = "linux"), target_env = "musl"),
|
||||
not(feature = "jemalloc")
|
||||
))]
|
||||
mod interface {
|
||||
#[allow(dead_code, clippy::unnecessary_wraps)]
|
||||
pub fn configure_memory_allocator() -> Result<(), String> {
|
||||
|
||||
Reference in New Issue
Block a user