From a11d9c4bf10a698caed33f6083336bf2df028a28 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Mon, 8 Jan 2024 11:23:55 +0000 Subject: [PATCH] feat: log tx processing time --- yarn-project/scripts/src/benchmarks/markdown.ts | 7 +++++++ .../sequencer-client/src/sequencer/public_processor.ts | 3 ++- yarn-project/types/src/stats/metrics.ts | 7 +++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/yarn-project/scripts/src/benchmarks/markdown.ts b/yarn-project/scripts/src/benchmarks/markdown.ts index fa4c340dffed..c98f6d05fcaf 100644 --- a/yarn-project/scripts/src/benchmarks/markdown.ts +++ b/yarn-project/scripts/src/benchmarks/markdown.ts @@ -182,6 +182,9 @@ export function getMarkdown() { const metricsByContractCount = Metrics.filter(m => m.groupBy === 'contract-count').map(m => m.name); const metricsByLeafCount = Metrics.filter(m => m.groupBy === 'leaf-count').map(m => m.name); + const metricsTxPxeProcessing = Metrics.filter(m => m.name === 'tx_pxe_processing_time_ms').map(m => m.name); + const metricsTxSeqProcessing = Metrics.filter(m => m.name === 'tx_sequencer_processing_time_ms').map(m => m.name); + const baseHash = process.env.BASE_COMMIT_HASH; const baseUrl = baseHash && `[\`${baseHash.slice(0, 8)}\`](${S3_URL}/benchmarks-v1/master/${baseHash}.json)`; const baseCommitText = baseUrl @@ -230,6 +233,10 @@ ${getTableContent(pick(benchmark, metricsByLeafCount), baseBenchmark, 'leaves')} Transaction sizes based on how many contracts are deployed in the tx. ${getTableContent(pick(benchmark, metricsByContractCount), baseBenchmark, 'deployed contracts')} +Transaction processing duration by data writes. +${getTableContent(pick(benchmark, metricsTxPxeProcessing), baseBenchmark, 'new commitments')} +${getTableContent(pick(benchmark, metricsTxSeqProcessing), baseBenchmark, 'public data writes')} + ${COMMENT_MARK} `; diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index b1d8875bda0e..88b470bd8349 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -172,7 +172,8 @@ export class PublicProcessor { this.log(`Processed public part of ${tx.data.end.newNullifiers[0]}`, { eventName: 'tx-sequencer-processing', duration: timer.ms(), - publicDataUpdateRequests: processedTransaction.data.end.publicDataUpdateRequests.length ?? 0, + publicDataUpdateRequests: + processedTransaction.data.end.publicDataUpdateRequests.filter(x => !x.leafSlot.isZero()).length ?? 0, ...tx.getStats(), } satisfies TxSequencerProcessingStats); diff --git a/yarn-project/types/src/stats/metrics.ts b/yarn-project/types/src/stats/metrics.ts index a66d31be3a16..8e8c3736fda1 100644 --- a/yarn-project/types/src/stats/metrics.ts +++ b/yarn-project/types/src/stats/metrics.ts @@ -7,8 +7,7 @@ export type MetricGroupBy = | 'circuit-name' | 'contract-count' | 'leaf-count' - | 'private-writes' - | 'public-writes'; + | 'data-writes'; /** Definition of a metric to track in benchmarks. */ export interface Metric { @@ -136,13 +135,13 @@ export const Metrics = [ }, { name: 'tx_pxe_processing_time_ms', - groupBy: 'private-writes', + groupBy: 'data-writes', description: 'Time to process the private part of a tx.', events: ['tx-pxe-processing'], }, { name: 'tx_sequencer_processing_time_ms', - groupBy: 'public-writes', + groupBy: 'data-writes', description: 'Time to process the public part of a tx.', events: ['tx-sequencer-processing'], },