mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 21:17:17 +00:00
456b313665
## Issue Addressed NA ## Proposed Changes Modify the configuration of [GNU malloc](https://www.gnu.org/software/libc/manual/html_node/The-GNU-Allocator.html) to reduce memory footprint. - Set `M_ARENA_MAX` to 4. - This reduces memory fragmentation at the cost of contention between threads. - Set `M_MMAP_THRESHOLD` to 2mb - This means that any allocation >= 2mb is allocated via an anonymous mmap, instead of on the heap/arena. This reduces memory fragmentation since we don't need to keep growing the heap to find big contiguous slabs of free memory. - ~~Run `malloc_trim` every 60 seconds.~~ - ~~This shaves unused memory from the top of the heap, preventing the heap from constantly growing.~~ - Removed, see: https://github.com/sigp/lighthouse/pull/2299#issuecomment-825322646 *Note: this only provides memory savings on the Linux (glibc) platform.* ## Additional Info I'm going to close #2288 in favor of this for the following reasons: - I've managed to get the memory footprint *smaller* here than with jemalloc. - This PR seems to be less of a dramatic change than bringing in the jemalloc dep. - The changes in this PR are strictly runtime changes, so we can create CLI flags which disable them completely. Since this change is wide-reaching and complex, it's nice to have an easy "escape hatch" if there are undesired consequences. ## TODO - [x] Allow configuration via CLI flags - [x] Test on Mac - [x] Test on RasPi. - [x] Determine if GNU malloc is present? - I'm not quite sure how to detect for glibc.. This issue suggests we can't really: https://github.com/rust-lang/rust/issues/33244 - [x] Make a clear argument regarding the affect of this on CPU utilization. - [x] Test with higher `M_ARENA_MAX` values. - [x] Test with longer trim intervals - [x] Add some stats about memory savings - [x] Remove `malloc_trim` calls & code
60 lines
2.0 KiB
TOML
60 lines
2.0 KiB
TOML
[package]
|
|
name = "lighthouse"
|
|
version = "1.3.0"
|
|
authors = ["Sigma Prime <contact@sigmaprime.io>"]
|
|
edition = "2018"
|
|
autotests = false
|
|
|
|
[features]
|
|
# Writes debugging .ssz files to /tmp during block processing.
|
|
write_ssz_files = ["beacon_node/write_ssz_files"]
|
|
# Compiles the BLS crypto code so that the binary is portable across machines.
|
|
portable = ["bls/supranational-portable"]
|
|
# Compiles BLST so that it always uses ADX instructions.
|
|
modern = ["bls/supranational-force-adx"]
|
|
# Uses the slower Milagro BLS library, which is written in native Rust.
|
|
milagro = ["bls/milagro"]
|
|
# Support minimal spec (used for testing only).
|
|
spec-minimal = []
|
|
# Support spec v0.12 (used by Medalla testnet).
|
|
spec-v12 = []
|
|
|
|
[dependencies]
|
|
beacon_node = { "path" = "../beacon_node" }
|
|
tokio = "1.1.0"
|
|
slog = { version = "2.5.2", features = ["max_level_trace"] }
|
|
sloggers = "1.0.1"
|
|
types = { "path" = "../consensus/types" }
|
|
bls = { path = "../crypto/bls" }
|
|
clap = "2.33.3"
|
|
env_logger = "0.8.2"
|
|
logging = { path = "../common/logging" }
|
|
slog-term = "2.6.0"
|
|
slog-async = "2.5.0"
|
|
environment = { path = "./environment" }
|
|
boot_node = { path = "../boot_node" }
|
|
futures = "0.3.7"
|
|
validator_client = { "path" = "../validator_client" }
|
|
account_manager = { "path" = "../account_manager" }
|
|
clap_utils = { path = "../common/clap_utils" }
|
|
eth2_network_config = { path = "../common/eth2_network_config" }
|
|
directory = { path = "../common/directory" }
|
|
lighthouse_version = { path = "../common/lighthouse_version" }
|
|
account_utils = { path = "../common/account_utils" }
|
|
remote_signer = { "path" = "../remote_signer" }
|
|
lighthouse_metrics = { path = "../common/lighthouse_metrics" }
|
|
lazy_static = "1.4.0"
|
|
serde_json = "1.0.59"
|
|
task_executor = { path = "../common/task_executor" }
|
|
malloc_utils = { path = "../common/malloc_utils" }
|
|
|
|
[dev-dependencies]
|
|
tempfile = "3.1.0"
|
|
validator_dir = { path = "../common/validator_dir" }
|
|
slashing_protection = { path = "../validator_client/slashing_protection" }
|
|
eth2_libp2p = { path = "../beacon_node/eth2_libp2p" }
|
|
|
|
[[test]]
|
|
name = "lighthouse_tests"
|
|
path = "tests/main.rs"
|