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
Changes from 1 commit
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
7 changes: 7 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,19 @@ 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 with --max-old-space-size=8GB");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.warn("Node.js heap size limit is too low, consider increasing it with --max-old-space-size=8GB");
logger.warn("Node.js heap size limit is too low, consider increasing it with --max-old-space-size=8192");

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's a way to make this more intuitive. Just appending --max-old-space-size won't do anything.
Eg:
./lodestar beacon --network mainnet ....... --max-old-space-size=8192

Copy link
Member

Choose a reason for hiding this comment

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

it will throw an error due to unknown arg, but we might wanna make it more obvious that it has to be set a node arg which a lot of the time is set via NODE_OPTIONS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, NODE_OPTIONS could be mentioned here. Or a link to our docs (that would have to be written).

Copy link
Member

Choose a reason for hiding this comment

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

This sounds like an ideal candidate to add to https://chainsafe.github.io/lodestar/faqs

}

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