Skip to content

Commit 90bf03d

Browse files
ch1boSupernaviX
andauthored
Count total_leios_bytes differently (#438)
* Count total_leios_bytes including the transactions generated This seems to be the only way to get a total sum of things that will be stored for FullWithoutIbs and FullWithTxReferences variants. Open point: this will cound transaction bytes double for the other variants and worsen theire spatial efficiency while we would not store txs double of course. * Actually count transaction bytes on the RB event This should now be more honest about the things we actually need to store. * Only count transaction sizes in variants where it matters --------- Co-authored-by: Simon Gellis <[email protected]>
1 parent 45c705b commit 90bf03d

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

sim-rs/sim-cli/src/events.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ impl EventMonitor {
241241
}
242242

243243
total_leios_txs += block_leios_txs.len() as u64;
244+
if matches!(
245+
self.variant,
246+
LeiosVariant::FullWithTxReferences | LeiosVariant::FullWithoutIbs
247+
) {
248+
// In variants where transactions are referenced by Leios blocks but not embedded in IBs,
249+
// referenced TXs need to be persisted separately. So count those referenced TX sizes
250+
// against Leios's "space efficiency".
251+
total_leios_bytes += block_leios_txs
252+
.iter()
253+
.map(|tx_id| txs.get(tx_id).unwrap().bytes)
254+
.sum::<u64>();
255+
}
244256
let unique_block_leios_txs =
245257
block_leios_txs.iter().copied().sorted().dedup().count();
246258
info!(
@@ -474,6 +486,7 @@ impl EventMonitor {
474486
let txs_per_ib = compute_stats(ibs.values().map(|ib| ib.txs.len() as f64));
475487
let bytes_per_ib = compute_stats(ibs.values().map(|ib| ib.bytes as f64));
476488
let ibs_per_tx = compute_stats(ibs_containing_tx.into_values());
489+
let txs_per_eb = compute_stats(ebs.values().map(|eb| eb.txs.len() as f64));
477490
let ibs_per_eb = compute_stats(ebs.values().map(|eb| eb.ibs.len() as f64));
478491
let ebs_per_ib = compute_stats(ebs_containing_ib.into_values());
479492
let ib_time_stats = compute_stats(times_to_reach_ib.iter().map(|t| t.as_secs_f64()));
@@ -487,7 +500,6 @@ impl EventMonitor {
487500
let votes_per_pool = compute_stats(votes_per_pool.into_values());
488501
let votes_per_eb = compute_stats(eb_votes.into_values());
489502
let votes_per_bundle = compute_stats(votes_per_bundle.into_values());
490-
let space_efficiency = leios_tx_bytes as f64 / total_leios_bytes as f64;
491503

492504
info!(
493505
"{} IB(s) were generated, on average {:.3} IB(s) per slot.",
@@ -530,6 +542,10 @@ impl EventMonitor {
530542
ebs.len(),
531543
ebs.len() as f64 / total_slots as f64
532544
);
545+
info!(
546+
"Each EB contained an average of {:.3} transaction(s) (stddev {:.3}). {} EB(s) were empty.",
547+
txs_per_eb.mean, txs_per_eb.std_dev, empty_ebs
548+
);
533549
info!(
534550
"Each EB contained an average of {:.3} IB(s) (stddev {:.3}). {} EB(s) were empty.",
535551
ibs_per_eb.mean, ibs_per_eb.std_dev, empty_ebs
@@ -564,9 +580,8 @@ impl EventMonitor {
564580
info!("{} L1 block(s) had a Leios endorsement.", leios_blocks_with_endorsements);
565581
info!("{} tx(s) ({}) were referenced by a Leios endorsement.", leios_txs, pretty_bytes(leios_tx_bytes, pbo.clone()));
566582
info!("{} tx(s) ({}) were included directly in a Praos block.", praos_txs, pretty_bytes(praos_tx_bytes, pbo.clone()));
567-
if self.variant != LeiosVariant::FullWithoutIbs {
568-
info!("Spatial efficiency: {}/{} ({:.3}%) of Leios bytes were unique transactions.", pretty_bytes(leios_tx_bytes, pbo.clone()), pretty_bytes(total_leios_bytes, pbo.clone()), space_efficiency * 100.);
569-
}
583+
info!("Spatial efficiency: {}/{} ({:.3}%) of Leios bytes were unique transactions.", pretty_bytes(leios_tx_bytes, pbo.clone()), pretty_bytes(total_leios_bytes, pbo.clone()),
584+
(leios_tx_bytes as f64 / total_leios_bytes as f64) * 100.);
570585
info!("{} tx(s) ({:.3}%) referenced by a Leios endorsement were redundant.", total_leios_txs - leios_txs, (total_leios_txs - leios_txs) as f64 / total_leios_txs as f64 * 100.);
571586
info!(
572587
"Each transaction took an average of {:.3}s (stddev {:.3}) to be included in an IB.",

0 commit comments

Comments
 (0)