From 01a13fdddc404ab84e76a8bc0684bf126b96e4df Mon Sep 17 00:00:00 2001 From: matthewkeil Date: Tue, 29 Oct 2024 13:55:26 +0700 Subject: [PATCH] feat: update metrics and remove stale comment --- .../src/chain/bls/multithread/jobItem.ts | 15 +++++---------- .../beacon-node/src/metrics/metrics/lodestar.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/beacon-node/src/chain/bls/multithread/jobItem.ts b/packages/beacon-node/src/chain/bls/multithread/jobItem.ts index b03e6b17a48..ba636f6d5d6 100644 --- a/packages/beacon-node/src/chain/bls/multithread/jobItem.ts +++ b/packages/beacon-node/src/chain/bls/multithread/jobItem.ts @@ -61,16 +61,11 @@ export async function jobItemWorkReq(job: JobQueueItem, metrics: Metrics | null) })), }; case JobQueueItemType.sameMessage: { - // This is slow code on main thread (mainly signature deserialization + group check). - // Ideally it can be taken off-thread, but in the mean time, keep track of total time spent here. - // As of July 2024, for a node subscribing to all subnets, with 1 signature per validator per epoch, - // it takes around 2.02 min to perform this operation for a single epoch. - // cpu profile on main thread has 250s idle so this only works until we reach 3M validators - // However, for normal node with only 2 to 7 subnet subscriptions per epoch this works until 27M validators - // and not a problem in the near future - // this is monitored on v1.21.0 https://github.com/ChainSafe/lodestar/pull/6894/files#r1687359225 - const timer = metrics?.blsThreadPool.aggregateWithRandomnessMainThreadDuration.startTimer(); - const {pk, sig} = await asyncAggregateWithRandomness(job.sets.map((set) => ({pk: set.publicKey, sig: set.signature}))); + metrics?.blsThreadPool.aggregateWithRandomnessSets.inc(job.sets); + const timer = metrics?.blsThreadPool.aggregateWithRandomnessJobTime.startTimer(); + const {pk, sig} = await asyncAggregateWithRandomness( + job.sets.map((set) => ({pk: set.publicKey, sig: set.signature})) + ); timer?.(); return { diff --git a/packages/beacon-node/src/metrics/metrics/lodestar.ts b/packages/beacon-node/src/metrics/metrics/lodestar.ts index f15e195faa2..477e6913304 100644 --- a/packages/beacon-node/src/metrics/metrics/lodestar.ts +++ b/packages/beacon-node/src/metrics/metrics/lodestar.ts @@ -497,9 +497,13 @@ export function createLodestarMetrics( name: "lodestar_bls_thread_pool_batchable_sig_sets_total", help: "Count of total batchable signature sets", }), - aggregateWithRandomnessMainThreadDuration: register.histogram({ - name: "lodestar_bls_thread_pool_aggregate_with_randomness_main_thread_time_seconds", - help: "Total time performing aggregateWithRandomness on main thread", + aggregateWithRandomnessSets: register.gauge({ + name: "lodestar_bls_thread_pool_aggregate_with_randomness_libuv_sets_total", + help: "Number of sets being asyncAggregateWithRandomness on libuv thread", + }), + aggregateWithRandomnessJobTime: register.histogram({ + name: "lodestar_bls_thread_pool_aggregate_with_randomness_libuv_job_time_seconds", + help: "Total time performing aggregateWithRandomness on libuv thread", buckets: [0.001, 0.005, 0.01, 0.1], }), pubkeysAggregationMainThreadDuration: register.histogram({