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 { ...@@ -31,6 +31,7 @@ interface BatchSubmitterMetrics {
batchesSubmitted: Counter<string> batchesSubmitted: Counter<string>
failedSubmissions: Counter<string> failedSubmissions: Counter<string>
malformedBatches: Counter<string> malformedBatches: Counter<string>
batchTxBuildTime: Gauge<string>
} }
export abstract class BatchSubmitter { export abstract class BatchSubmitter {
...@@ -293,6 +294,11 @@ export abstract class BatchSubmitter { ...@@ -293,6 +294,11 @@ export abstract class BatchSubmitter {
help: 'Count of malformed batches', help: 'Count of malformed batches',
registers: [metrics.registry], 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 { ...@@ -154,6 +154,9 @@ export class StateBatchSubmitter extends BatchSubmitter {
startBlock: number, startBlock: number,
endBlock: number endBlock: number
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const batchTxBuildStart = performance.now()
const batch = await this._generateStateCommitmentBatch(startBlock, endBlock) const batch = await this._generateStateCommitmentBatch(startBlock, endBlock)
const calldata = this.chainContract.interface.encodeFunctionData( const calldata = this.chainContract.interface.encodeFunctionData(
'appendStateBatch', 'appendStateBatch',
...@@ -169,6 +172,9 @@ export class StateBatchSubmitter extends BatchSubmitter { ...@@ -169,6 +172,9 @@ export class StateBatchSubmitter extends BatchSubmitter {
return return
} }
const batchTxBuildEnd = performance.now()
this.metrics.batchTxBuildTime.set(batchTxBuildEnd - batchTxBuildStart)
const offsetStartsAtIndex = startBlock - this.blockOffset const offsetStartsAtIndex = startBlock - this.blockOffset
this.logger.debug('Submitting batch.', { calldata }) this.logger.debug('Submitting batch.', { calldata })
......
...@@ -203,6 +203,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -203,6 +203,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return return
} }
const batchTxBuildStart = performance.now()
const params = await this._generateSequencerBatchParams( const params = await this._generateSequencerBatchParams(
startBlock, startBlock,
endBlock endBlock
...@@ -226,6 +228,10 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -226,6 +228,10 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
if (!wasBatchTruncated && !this._shouldSubmitBatch(batchSizeInBytes)) { if (!wasBatchTruncated && !this._shouldSubmitBatch(batchSizeInBytes)) {
return return
} }
const batchTxBuildEnd = performance.now()
this.metrics.batchTxBuildTime.set(batchTxBuildEnd - batchTxBuildStart)
this.metrics.numTxPerBatch.observe(endBlock - startBlock) this.metrics.numTxPerBatch.observe(endBlock - startBlock)
const l1tipHeight = await this.signer.provider.getBlockNumber() const l1tipHeight = await this.signer.provider.getBlockNumber()
this.logger.debug('Submitting batch.', { 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