Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: warn when heap limit is too low #6722

Merged
merged 7 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/pages/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
jeluard marked this conversation as resolved.
Show resolved Hide resolved

```
jeluard marked this conversation as resolved.
Show resolved Hide resolved
NODE_OPTIONS: --max-old-space-size=8192
```
:::

### Using Kubernetes

:::note "Unknown arguments error"
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/cmds/beacon/handler.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -28,13 +29,21 @@ 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.
*/
export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise<void> {
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. See https://chainsafe.github.io/lodestar/faqs#running-a-node"
jeluard marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would kinda be nice if we could directly link to the heap limit instead of top level header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not doable with the current docs structure, would require some changes here.

);
}

// initialize directories
mkdir(beaconPaths.dataDir);
mkdir(beaconPaths.beaconDir);
Expand Down
Loading