Compare commits

...

5 Commits

Author SHA1 Message Date
Paul Hauner
3b600acdc5 v1.4.0 (#2402)
## Issue Addressed

NA

## Proposed Changes

- Bump versions and update `Cargo.lock`

## Additional Info

NA

## TODO

- [x] Ensure #2398 gets merged succesfully
2021-06-10 01:44:49 +00:00
Paul Hauner
b383836418 Modify Malloc Tuning (#2398)
## Issue Addressed

NA

## Proposed Changes

I've noticed some of the SigP Prater nodes struggling on v1.4.0-rc.0. I suspect this is due to the changes in #2296. Specifically, the trade-off which lowered the memory footprint whilst increasing runtime on some functions.

Presently, this PR is documenting my testing on Prater.

## Additional Info

NA
2021-06-09 02:30:06 +00:00
Paul Hauner
4a6f2fac81 Only perform malloc tuning for beacon node (#2397)
## Issue Addressed

NA

## Proposed Changes

Only run `configure_memory_alllocator` for the BN process.

I noticed that VC memory usage increases significantly with the new malloc tuning parameters. This was also raised by a user on [r/ethstaker](https://www.reddit.com/r/ethstaker/comments/nr8998/lighthouse_prerelease_v140rc0/h0fnt9l?utm_source=share&utm_medium=web2x&context=3).

There wasn't any issue with memory usage by the VC before we implemented #2296, so I think we were a bit overzealous when we allowed these changes to affect it. This PR allows things that weren't broken to remain unfixed.

## Additional Info

NA
2021-06-07 02:34:10 +00:00
Paul Hauner
93100f221f Make less logs for attn with unknown head (#2395)
## Issue Addressed

NA

## Proposed Changes

I am starting to see a lot of slog-async overflows (i.e., too many logs) on Prater whenever we see attestations for an unknown block. Since these logs are identical (except for peer id) and we expose volume/count of these errors via `metrics::GOSSIP_ATTESTATION_ERRORS_PER_TYPE`, I took the following actions to remove them from `DEBUG` logs:

- Push the "Attestation for unknown block" log to trace.
- Add a debug log in `search_for_block`. In effect, this should serve as a de-duped version of the previous, downgraded log.

## Additional Info

TBC
2021-06-07 02:34:09 +00:00
Pawan Dhananjay
502402c6b9 Fix options for --eth1-endpoints flag (#2392)
## Issue Addressed

N/A

## Proposed Changes

Set `config.sync_eth1_chain` to true when using just the  `--eth1-endpoints` flag (without `--eth1`).
2021-06-04 00:10:59 +00:00
13 changed files with 24 additions and 62 deletions

9
Cargo.lock generated
View File

@@ -630,7 +630,7 @@ dependencies = [
[[package]]
name = "beacon_node"
version = "1.4.0-rc.0"
version = "1.4.0"
dependencies = [
"beacon_chain",
"clap",
@@ -844,7 +844,7 @@ dependencies = [
[[package]]
name = "boot_node"
version = "1.4.0-rc.0"
version = "1.4.0"
dependencies = [
"beacon_node",
"clap",
@@ -3352,7 +3352,7 @@ dependencies = [
[[package]]
name = "lcli"
version = "1.4.0-rc.0"
version = "1.4.0"
dependencies = [
"account_utils",
"bls",
@@ -3729,7 +3729,7 @@ dependencies = [
[[package]]
name = "lighthouse"
version = "1.4.0-rc.0"
version = "1.4.0"
dependencies = [
"account_manager",
"account_utils",
@@ -3884,7 +3884,6 @@ dependencies = [
"lazy_static",
"libc",
"lighthouse_metrics",
"num_cpus",
"parking_lot",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "beacon_node"
version = "1.4.0-rc.0"
version = "1.4.0"
authors = ["Paul Hauner <paul@paulhauner.com>", "Age Manning <Age@AgeManning.com"]
edition = "2018"

View File

@@ -797,7 +797,7 @@ impl<T: BeaconChainTypes> Worker<T> {
// TODO: Maintain this attestation and re-process once sync completes
// TODO: We then score based on whether we can download the block and re-process.
debug!(
trace!(
self.log,
"Attestation for unknown block";
"peer_id" => %peer_id,

View File

@@ -554,6 +554,13 @@ impl<T: BeaconChainTypes> SyncManager<T> {
return;
}
debug!(
self.log,
"Searching for block";
"peer_id" => %peer_id,
"block" => %block_hash
);
let request = BlocksByRootRequest {
block_roots: VariableList::from(vec![block_hash]),
};

View File

@@ -190,6 +190,7 @@ pub fn get_config<E: EthSpec>(
client_config.eth1.endpoints = vec![SensitiveUrl::parse(endpoint)
.map_err(|e| format!("eth1-endpoint was an invalid URL: {:?}", e))?];
} else if let Some(endpoints) = cli_args.value_of("eth1-endpoints") {
client_config.sync_eth1_chain = true;
client_config.eth1.endpoints = endpoints
.split(',')
.map(|s| SensitiveUrl::parse(s))

View File

@@ -1,6 +1,6 @@
[package]
name = "boot_node"
version = "1.4.0-rc.0"
version = "1.4.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"

View File

@@ -16,7 +16,7 @@ pub const VERSION: &str = git_version!(
// NOTE: using --match instead of --exclude for compatibility with old Git
"--match=thiswillnevermatchlol"
],
prefix = "Lighthouse/v1.4.0-rc.0-",
prefix = "Lighthouse/v1.4.0-",
fallback = "unknown"
);

View File

@@ -11,4 +11,3 @@ lighthouse_metrics = { path = "../lighthouse_metrics" }
lazy_static = "1.4.0"
libc = "0.2.79"
parking_lot = "0.11.0"
num_cpus = "1.13.0"

View File

@@ -21,37 +21,20 @@ use std::result::Result;
/// NODES_PER_VALIDATOR * VALIDATORS_PER_ARENA * 32 = 15 * 4096 * 32 = 1.875 MiB
const OPTIMAL_MMAP_THRESHOLD: c_int = 2 * 1_024 * 1_024;
/// The maximum number of arenas allowed to be created by malloc.
///
/// See `ArenaMaxSetting` docs for details.
const OPTIMAL_ARENA_MAX: ArenaMaxSetting = ArenaMaxSetting::NumCpus;
/// Constants used to configure malloc internals.
///
/// Source:
///
/// https://github.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/malloc/malloc.h#L115-L123
const M_MMAP_THRESHOLD: c_int = -4;
const M_ARENA_MAX: c_int = -8;
/// Environment variables used to configure malloc.
///
/// Source:
///
/// https://man7.org/linux/man-pages/man3/mallopt.3.html
const ENV_VAR_ARENA_MAX: &str = "MALLOC_ARENA_MAX";
const ENV_VAR_MMAP_THRESHOLD: &str = "MALLOC_MMAP_THRESHOLD_";
#[allow(dead_code)]
enum ArenaMaxSetting {
/// Do not set any value for MALLOC_ARENA_MAX, leave it as default.
DoNotSet,
/// Set a fixed value.
Fixed(c_int),
/// Read the number of CPUs at runtime and use that value.
NumCpus,
}
lazy_static! {
pub static ref GLOBAL_LOCK: Mutex<()> = <_>::default();
}
@@ -123,20 +106,6 @@ pub fn scrape_mallinfo_metrics() {
/// Perform all configuration routines.
pub fn configure_glibc_malloc() -> Result<(), String> {
if !env_var_present(ENV_VAR_ARENA_MAX) {
let arena_max = match OPTIMAL_ARENA_MAX {
ArenaMaxSetting::DoNotSet => None,
ArenaMaxSetting::Fixed(n) => Some(n),
ArenaMaxSetting::NumCpus => Some(num_cpus::get() as c_int),
};
if let Some(max) = arena_max {
if let Err(e) = malloc_arena_max(max) {
return Err(format!("failed (code {}) to set malloc max arena count", e));
}
}
}
if !env_var_present(ENV_VAR_MMAP_THRESHOLD) {
if let Err(e) = malloc_mmap_threshold(OPTIMAL_MMAP_THRESHOLD) {
return Err(format!("failed (code {}) to set malloc mmap threshold", e));
@@ -151,19 +120,6 @@ fn env_var_present(name: &str) -> bool {
env::var(name) != Err(env::VarError::NotPresent)
}
/// Uses `mallopt` to set the `M_ARENA_MAX` value, specifying the number of memory arenas to be
/// created by malloc.
///
/// Generally speaking, a smaller arena count reduces memory fragmentation at the cost of memory contention
/// between threads.
///
/// ## Resources
///
/// - https://man7.org/linux/man-pages/man3/mallopt.3.html
fn malloc_arena_max(num_arenas: c_int) -> Result<(), c_int> {
into_result(mallopt(M_ARENA_MAX, num_arenas))
}
/// Uses `mallopt` to set the `M_MMAP_THRESHOLD` value, specifying the threshold where objects of this
/// size or larger are allocated via an `mmap`.
///
@@ -198,11 +154,6 @@ fn into_result(result: c_int) -> Result<(), c_int> {
mod tests {
use super::*;
#[test]
fn malloc_arena_max_does_not_panic() {
malloc_arena_max(2).unwrap();
}
#[test]
fn malloc_mmap_threshold_does_not_panic() {
malloc_mmap_threshold(OPTIMAL_MMAP_THRESHOLD).unwrap();

View File

@@ -1,7 +1,7 @@
[package]
name = "lcli"
description = "Lighthouse CLI (modeled after zcli)"
version = "1.4.0-rc.0"
version = "1.4.0"
authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"

View File

@@ -1,6 +1,6 @@
[package]
name = "lighthouse"
version = "1.4.0-rc.0"
version = "1.4.0"
authors = ["Sigma Prime <contact@sigmaprime.io>"]
edition = "2018"
autotests = false

View File

@@ -165,7 +165,11 @@ fn main() {
// Configure the allocator early in the process, before it has the chance to use the default values for
// anything important.
if !matches.is_present(DISABLE_MALLOC_TUNING_FLAG) {
//
// Only apply this optimization for the beacon node. It's the only process with a substantial
// memory footprint.
let is_beacon_node = matches.subcommand_name() == Some("beacon_node");
if is_beacon_node && !matches.is_present(DISABLE_MALLOC_TUNING_FLAG) {
if let Err(e) = configure_memory_allocator() {
eprintln!(
"Unable to configure the memory allocator: {} \n\

View File

@@ -257,6 +257,7 @@ fn eth1_endpoints_flag() {
"https://infura.io/secret"
);
assert_eq!(config.eth1.endpoints[1].to_string(), "https://infura.io/");
assert!(config.sync_eth1_chain);
});
}
#[test]