-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
🚀 Feature
We should figure out what are the biggest bottlenecks when calling prepare_advance_to_next_quorum_block
with a full block.
For reference, this is WIP work you can build on for a canonical test chain generator:
- [Feature] Add testchain generator #2946
- Add support for passing in a custom genesis block to testchain_generator #2947
In order to figure out the biggest bottlenecks, we should
- Adjust the test chain generator to be able to read transactions from disk to be included in validator's proposals
- Adjust the test chain generator to be able to not just export a ledger, but also an uncomitted subdag and transmissions. Generate a subdag consisting of 2 rounds, 40 validatrors, 50 transactions per proposal.
With the above in hand, you should then in a new test be able to read the subdag and transmissions from disk in order to profile prepare_advance_to_next_quorum_block
. You will also either to read in an appropriate 40 validator dev genesis block.
A previous hacky approach to the profiling:
#[test]
fn test_prepare_advance_to_next_quorum_block() -> anyhow::Result<()> {
// Deserialize the block from a file.
let genesis_bytes = std::fs::read("genesis.bin").unwrap();
let genesis: Block<CurrentNetwork> = bincode::deserialize(&genesis_bytes).unwrap();
// Initialize the ledger.
let ledger = CurrentLedger::load(genesis.clone(), StorageMode::Production).unwrap();
let core_ledger = Arc::new(CoreLedgerService::new(ledger.clone(), Default::default()));
// Read subdag from file.
let subdag_bytes = std::fs::read("subdag.bin").unwrap();
let subdag: Subdag<CurrentNetwork> = bincode::deserialize(&subdag_bytes).unwrap();
// Read transmissions from file.
let transmissions_bytes = std::fs::read("transmissions.bin").unwrap();
let transmissions: IndexMap<TransmissionID<CurrentNetwork>, Transmission<CurrentNetwork>> =
bincode::deserialize(&transmissions_bytes).unwrap();
// Deserialize the individual transmissions.
let transmissions = transmissions
.into_iter()
.map(|(id, transmission)| {
let new_transmission = match transmission {
Transmission::Transaction(tx) => {
let deserialized_tx = tx.deserialize_blocking().expect("Failed to deserialize transaction");
Transmission::from(deserialized_tx)
}
Transmission::Solution(solution) => {
let deserialized_solution =
solution.deserialize_blocking().expect("Failed to deserialize solution");
Transmission::from(deserialized_solution)
}
Transmission::Ratification => panic!("unexpected"),
};
(id, new_transmission)
})
.collect::<IndexMap<_, _>>();
// Start flamegraph or profiling
// Generate block.
let _block = core_ledger.prepare_advance_to_next_quorum_block(subdag, transmissions)?;
return Ok(());
}
Metadata
Metadata
Assignees
Labels
No labels