Skip to content

Commit

Permalink
feat(beacon-node): network worker new space adjustment (#5829)
Browse files Browse the repository at this point in the history
* feat: up worker maxYoungGenerationSizeMb to 32

* feat: up worker maxYoungGenerationSizeMb to 64

* feat(dashboards): update memory panels on vm/host

* feat(network-worker): update new space to 512mb

* fix(dashboard): add newline to end of file

* fix(dashboard): lint vm

* feat: up worker maxYoungGenerationSizeMb to 32

* feat: up worker maxYoungGenerationSizeMb to 64

* feat(dashboards): update memory panels on vm/host

* feat(network-worker): update new space to 512mb

* fix(dashboard): add newline to end of file

* fix(dashboard): lint vm

* fix: dashboard lint

* feat(network-worker): maxYoungGenerationSizeMb to 128mb

* fix(dashboards): revert dashboard changes

* fix: revert changes to dashboard and package.json

* feat(network-worker): use young generation value from research

* feat(cli): add hidden maxYoungGenerationSizeMb

* fix: update bad merge conflict resolution

* fix: update bad merge conflict resolution

* chore: lint --fix code
  • Loading branch information
matthewkeil authored Aug 24, 2023
1 parent 4bd554f commit 1b40a91
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,21 @@ export class WorkerNetworkCore implements INetworkCore {
loggerOpts: modules.logger.toOpts(),
};

const worker = new Worker("./networkCoreWorker.js", {workerData} as ConstructorParameters<typeof Worker>[1]);
const worker = new Worker("./networkCoreWorker.js", {
workerData,
/**
* maxYoungGenerationSizeMb defaults to 152mb through the cli option defaults.
* That default value was determined via https://github.com/ChainSafe/lodestar/issues/2115 and
* should be tuned further as needed. If we update network code and see substantial
* difference in the quantity of garbage collected this should get updated. A value that is
* too low will result in too much GC time and a value that is too high causes increased mark
* and sweep for some reason (which is much much slower than scavenge). A marginally too high
* number causes detrimental slowdown from increased variable lookup time. Empirical evidence
* showed that there is a pretty big window of "correct" values but we can always tune as
* necessary
*/
resourceLimits: {maxYoungGenerationSizeMb: opts.maxYoungGenerationSizeMb},
} as ConstructorParameters<typeof Worker>[1]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const workerApi = (await spawn<any>(worker, {
Expand Down
3 changes: 3 additions & 0 deletions packages/beacon-node/src/network/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface NetworkOptions
version?: string;
private?: boolean;
useWorker?: boolean;
maxYoungGenerationSizeMb?: number;
}

export const defaultNetworkOptions: NetworkOptions = {
Expand All @@ -32,6 +33,8 @@ export const defaultNetworkOptions: NetworkOptions = {
discv5: null,
rateLimitMultiplier: 1,
useWorker: true,
// default set via research in https://github.com/ChainSafe/lodestar/issues/2115
maxYoungGenerationSizeMb: 152,
// subscribe to 2 subnets per node since v1.10
deterministicLongLivedAttnets: true,
// subscribe 2 slots before aggregator dutied slot to get stable mesh peers as monitored on goerli
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/options/beaconNodeOptions/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type NetworkArgs = {
"network.rateLimitMultiplier"?: number;
"network.maxGossipTopicConcurrency"?: number;
"network.useWorker"?: boolean;
"network.maxYoungGenerationSizeMb"?: number;

/** @deprecated This option is deprecated and should be removed in next major release. */
"network.requestCountPeerLimit"?: number;
Expand Down Expand Up @@ -153,6 +154,7 @@ export function parseArgs(args: NetworkArgs): IBeaconNodeOptions["network"] {
rateLimitMultiplier: args["network.rateLimitMultiplier"],
maxGossipTopicConcurrency: args["network.maxGossipTopicConcurrency"],
useWorker: args["network.useWorker"],
maxYoungGenerationSizeMb: args["network.maxYoungGenerationSizeMb"],
};
}

Expand Down Expand Up @@ -385,4 +387,12 @@ export const options: CliCommandOptions<NetworkArgs> = {
hidden: true,
group: "network",
},

"network.maxYoungGenerationSizeMb": {
type: "number",
hidden: true,
group: "network",
description: "Max size of young generation in megabytes. Defaults to 152mb",
defaultDescription: String(defaultOptions.network.maxYoungGenerationSizeMb),
},
};
2 changes: 2 additions & 0 deletions packages/cli/test/unit/options/beaconNodeOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe("options / beaconNodeOptions", () => {
"network.rateLimitMultiplier": 1,
"network.maxGossipTopicConcurrency": 64,
"network.useWorker": true,
"network.maxYoungGenerationSizeMb": 152,

"sync.isSingleNode": true,
"sync.disableProcessAsChainSegment": true,
Expand Down Expand Up @@ -199,6 +200,7 @@ describe("options / beaconNodeOptions", () => {
rateLimitMultiplier: 1,
maxGossipTopicConcurrency: 64,
useWorker: true,
maxYoungGenerationSizeMb: 152,
},
sync: {
isSingleNode: true,
Expand Down

0 comments on commit 1b40a91

Please sign in to comment.