|
fn insert_decided_block( |
|
&self, |
|
decided_block: DecidedBlock, |
|
proposer: Address, |
|
) -> Result<(), StoreError> { |
|
let start = Instant::now(); |
|
let mut write_bytes = 0; |
|
|
|
let height = decided_block.height(); |
|
let tx = self.db.begin_write()?; |
|
|
|
{ |
|
let mut blocks = tx.open_table(DECIDED_BLOCKS_TABLE)?; |
|
let block_bytes = encode_execution_payload(&decided_block.execution_payload); |
|
#[allow(clippy::arithmetic_side_effects)] |
|
{ |
|
write_bytes += block_bytes.len(); |
|
} |
|
blocks.insert(height, block_bytes)?; |
|
} |
|
|
|
self.insert_certificate( |
|
&tx, |
|
decided_block.certificate, |
|
CommitCertificateType::Minimal, |
|
Some(proposer), |
|
)?; |
|
|
|
tx.commit()?; |
|
|
|
self.update_write_metrics(write_bytes, start.elapsed()); |
|
|
|
Ok(()) |
|
} |
In insert_decided_block above, start.elapsed() spans the entire function body including insert_certificate(), which itself calls update_write_metrics with its own internal timer, then:
- The write time in
insert_decided_block is for block bytes, but it ends up including the write time for certificate bytes,
- However
insert_certificate also reports its own write time internally.
Therefore, the certificate insertion time is double counted in the aggregated write_time metric because both calls accumulate into the same counter.
Impact: The write latency metric overstates actual DB write time by roughly one cert encoding + insert cycle per insert_decided_block call, causing metric inaccuracy.
arc-node/crates/consensus-db/src/store.rs
Lines 457 to 490 in a85368c
In insert_decided_block above,
start.elapsed()spans the entire function body includinginsert_certificate(), which itself callsupdate_write_metricswith its own internal timer, then:insert_decided_blockis for block bytes, but it ends up including the write time for certificate bytes,insert_certificatealso reports its own write time internally.Therefore, the certificate insertion time is double counted in the aggregated
write_timemetric because both calls accumulate into the same counter.Impact: The write latency metric overstates actual DB write time by roughly one cert encoding + insert cycle per
insert_decided_blockcall, causing metric inaccuracy.