-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Labels
A-engineRelated to the engine implementationRelated to the engine implementationC-perfA change motivated by improving speed, memory usage or disk footprintA change motivated by improving speed, memory usage or disk footprint
Description
Parallelize block validation operations
Currently, block validation operations in the engine tree execute sequentially. These operations are independent and can be parallelized for performance improvements.
Current implementation
The handle_execution_error
method performs sequential validation:
- First calls
validate_block_inner
- Then calls
validate_header_against_parent
Other Areas to look at:
Proposed implementation
Execute both validation operations in parallel using rayon::join
:
let (block_validation, parent_validation) = rayon::join(
|| self.validate_block_inner(&block),
|| self.consensus.validate_header_against_parent(block.sealed_header(), parent_block)
);
- we can possibly parallelise validate_block_inner as well -
fn validate_block_inner(&self, block: &RecoveredBlock<N::Block>) -> Result<(), ConsensusError> {
Other parallelization opportunities
- Transaction signature recovery - Recover signatures for all transactions in a block in parallel
- Multiple block validation - When validating multiple blocks in a batch, validate them in parallel
- State prefetching - Prefetch state data in parallel while executing transactions (already partially implemented in prewarm.rs)
- Consensus checks - Parallelize independent consensus validation checks within
validate_block_inner
Concerns / Thoughts
The question tho is whether there’s a bigger opportunity to eliminate and simplify instead of optimising? and whether the overhead > parallelisation
Metadata
Metadata
Assignees
Labels
A-engineRelated to the engine implementationRelated to the engine implementationC-perfA change motivated by improving speed, memory usage or disk footprintA change motivated by improving speed, memory usage or disk footprint
Type
Projects
Status
In Progress