From 821e4b1adb64dbd013896e9b5f766f152dc23d23 Mon Sep 17 00:00:00 2001 From: Julien Eluard Date: Wed, 1 May 2024 20:55:38 +0200 Subject: [PATCH 1/7] chore: warn when heap limit is too low --- packages/cli/src/cmds/beacon/handler.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index 1ffde48133cb..be790fe0496a 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -1,4 +1,5 @@ import path from "node:path"; +import {getHeapStatistics} from "node:v8"; import {Registry} from "prom-client"; import {ErrorAborted} from "@lodestar/utils"; import {LevelDbController} from "@lodestar/db"; @@ -28,6 +29,7 @@ import {initPeerIdAndEnr} from "./initPeerIdAndEnr.js"; const DEFAULT_RETENTION_SSZ_OBJECTS_HOURS = 15 * 24; const HOURS_TO_MS = 3600 * 1000; +const EIGHT_GB = 8 * 1024 * 1024 * 1024; /** * Runs a beacon node. @@ -35,6 +37,11 @@ const HOURS_TO_MS = 3600 * 1000; export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise { const {config, options, beaconPaths, network, version, commit, peerId, logger} = await beaconHandlerInit(args); + const heapSizeLimit = getHeapStatistics().heap_size_limit; + if (heapSizeLimit < EIGHT_GB) { + logger.warn("Node.js heap size limit is too low, consider increasing it with --max-old-space-size=8GB"); + } + // initialize directories mkdir(beaconPaths.dataDir); mkdir(beaconPaths.beaconDir); From e5af9be994fbf795adbdc9c96cc20bc52dc15f2d Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 1 May 2024 12:22:27 -0700 Subject: [PATCH 2/7] chore: units Co-authored-by: Nico Flaig --- packages/cli/src/cmds/beacon/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index be790fe0496a..c557b33a722a 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -39,7 +39,7 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise Date: Thu, 2 May 2024 07:52:06 +0200 Subject: [PATCH 3/7] chore: address comments --- packages/cli/src/cmds/beacon/handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index c557b33a722a..453960cd8890 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -39,7 +39,9 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise Date: Sat, 4 May 2024 10:31:58 +0200 Subject: [PATCH 4/7] chore: added faq element --- docs/pages/faqs.md | 12 ++++++++++++ packages/cli/src/cmds/beacon/handler.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/pages/faqs.md b/docs/pages/faqs.md index 01732c5c11fa..bdfcb338d87f 100644 --- a/docs/pages/faqs.md +++ b/docs/pages/faqs.md @@ -4,6 +4,18 @@ This section of the documentation will cover common questions and encounters oft ## Troubleshooting Lodestar +### Running a beacon node + +:::note "Heap memory limit" +Lodestar beacon node requires at least 8GB of heap space. While the `lodestar` script and the official docker image correctly sets the appropriate value, it might be necessary to manually set it for some specific scenario. + +The simplest way to achieve this is via the `NODE_OPTIONS` environment variable. + +``` +NODE_OPTIONS: --max-old-space-size=8192 +``` +::: + ### Using Kubernetes :::note "Unknown arguments error" diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index 453960cd8890..ce2d8c057978 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -40,7 +40,7 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise Date: Fri, 10 May 2024 12:50:25 -0700 Subject: [PATCH 5/7] chore: address comments Co-authored-by: Nico Flaig --- docs/pages/faqs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/faqs.md b/docs/pages/faqs.md index bdfcb338d87f..7eeba0254734 100644 --- a/docs/pages/faqs.md +++ b/docs/pages/faqs.md @@ -9,7 +9,7 @@ This section of the documentation will cover common questions and encounters oft :::note "Heap memory limit" Lodestar beacon node requires at least 8GB of heap space. While the `lodestar` script and the official docker image correctly sets the appropriate value, it might be necessary to manually set it for some specific scenario. -The simplest way to achieve this is via the `NODE_OPTIONS` environment variable. +The simplest way to achieve this is via the `NODE_OPTIONS` environment variable or by passing [`--max-old-space-size`](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes) directly to the node binary ``` NODE_OPTIONS: --max-old-space-size=8192 From 7d6a52c68b3e2a08ed13feabe88dc0bd7f483cc1 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 10 May 2024 12:50:57 -0700 Subject: [PATCH 6/7] chore: address comments Co-authored-by: Nico Flaig --- packages/cli/src/cmds/beacon/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/cmds/beacon/handler.ts b/packages/cli/src/cmds/beacon/handler.ts index ce2d8c057978..444bbba8510e 100644 --- a/packages/cli/src/cmds/beacon/handler.ts +++ b/packages/cli/src/cmds/beacon/handler.ts @@ -40,7 +40,7 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise Date: Fri, 10 May 2024 22:05:40 +0200 Subject: [PATCH 7/7] chore: address comments --- docs/pages/faqs.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/pages/faqs.md b/docs/pages/faqs.md index 7eeba0254734..d86f2a37471e 100644 --- a/docs/pages/faqs.md +++ b/docs/pages/faqs.md @@ -11,9 +11,10 @@ Lodestar beacon node requires at least 8GB of heap space. While the `lodestar` s The simplest way to achieve this is via the `NODE_OPTIONS` environment variable or by passing [`--max-old-space-size`](https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes) directly to the node binary -``` +```bash NODE_OPTIONS: --max-old-space-size=8192 ``` + ::: ### Using Kubernetes