Skip to content

Commit

Permalink
test add jemalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed Feb 10, 2021
1 parent e4b6213 commit db6fda6
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions beacon_node/http_metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lazy_static = "1.4.0"
eth2 = { path = "../../common/eth2" }
lighthouse_version = { path = "../../common/lighthouse_version" }
warp_utils = { path = "../../common/warp_utils" }
jemalloc-ctl = "0.3.3"

[dev-dependencies]
tokio = { version = "0.3.2", features = ["sync"] }
Expand Down
7 changes: 7 additions & 0 deletions beacon_node/http_metrics/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::Context;
use beacon_chain::BeaconChainTypes;
use lighthouse_metrics::{Encoder, TextEncoder};
use jemalloc_ctl::{stats, epoch};

pub use lighthouse_metrics::*;

Expand Down Expand Up @@ -47,3 +48,9 @@ pub fn gather_prometheus_metrics<T: BeaconChainTypes>(

String::from_utf8(buffer).map_err(|e| format!("Failed to encode prometheus info: {:?}", e))
}

pub fn scrape_jemalloc_metrics() {
let e = epoch::mib().unwrap();
let allocated = stats::allocated::mib().unwrap();
let resident = stats::resident::mib().unwrap();
}
1 change: 1 addition & 0 deletions lighthouse/environment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ futures = "0.3.7"
parking_lot = "0.11.0"
slog-json = "2.3.0"
exit-future = "0.2.0"
jemallocator = "0.3.2"
4 changes: 4 additions & 0 deletions lighthouse/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ use task_executor::TaskExecutor;
use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
use types::{EthSpec, MainnetEthSpec, MinimalEthSpec, V012LegacyEthSpec};

/// Global allocator
#[global_allocator]
pub static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";
const LOG_CHANNEL_SIZE: usize = 2048;
/// The maximum time in seconds the client will wait for all internal tasks to shutdown.
Expand Down

0 comments on commit db6fda6

Please sign in to comment.