Skip to content

Commit

Permalink
feat: log tx processing time
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Jan 8, 2024
1 parent c10be24 commit a11d9c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions yarn-project/scripts/src/benchmarks/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')}
</details>
${COMMENT_MARK}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 3 additions & 4 deletions yarn-project/types/src/stats/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'],
},
Expand Down

0 comments on commit a11d9c4

Please sign in to comment.