Commit 3eb5590b authored by Conner Fromknecht's avatar Conner Fromknecht

feat: add batchTxBuildTime performance gauge

This will allow us to accurately track how long we spend building
batches as we look to increase maxTxBatchSize.
parent 158743bc
---
'@eth-optimism/batch-submitter': patch
---
adds batchTxBuildTime gauge
......@@ -31,6 +31,7 @@ interface BatchSubmitterMetrics {
batchesSubmitted: Counter<string>
failedSubmissions: Counter<string>
malformedBatches: Counter<string>
batchTxBuildTime: Gauge<string>
}
export abstract class BatchSubmitter {
......@@ -293,6 +294,11 @@ export abstract class BatchSubmitter {
help: 'Count of malformed batches',
registers: [metrics.registry],
}),
batchTxBuildTime: new metrics.client.Gauge({
name: 'batch_tx_build_time',
help: 'Time to construct batch transaction',
registers: [metrics.registry],
}),
}
}
}
......@@ -154,6 +154,9 @@ export class StateBatchSubmitter extends BatchSubmitter {
startBlock: number,
endBlock: number
): Promise<TransactionReceipt> {
const batchTxBuildStart = performance.now()
const batch = await this._generateStateCommitmentBatch(startBlock, endBlock)
const calldata = this.chainContract.interface.encodeFunctionData(
'appendStateBatch',
......@@ -169,6 +172,9 @@ export class StateBatchSubmitter extends BatchSubmitter {
return
}
const batchTxBuildEnd = performance.now()
this.metrics.batchTxBuildTime.set(batchTxBuildEnd - batchTxBuildStart)
const offsetStartsAtIndex = startBlock - this.blockOffset
this.logger.debug('Submitting batch.', { calldata })
......
......@@ -203,6 +203,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return
}
const batchTxBuildStart = performance.now()
const params = await this._generateSequencerBatchParams(
startBlock,
endBlock
......@@ -226,6 +228,10 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
if (!wasBatchTruncated && !this._shouldSubmitBatch(batchSizeInBytes)) {
return
}
const batchTxBuildEnd = performance.now()
this.metrics.batchTxBuildTime.set(batchTxBuildEnd - batchTxBuildStart)
this.metrics.numTxPerBatch.observe(endBlock - startBlock)
const l1tipHeight = await this.signer.provider.getBlockNumber()
this.logger.debug('Submitting batch.', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment