hiero-ledger / hiero-ledger/hiero-consensus-node
Investigate parallel reconnect pipeline with deferred hashing for virtual maps
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
### Description
Current virtual map reconnect couples leaf synchronization with hashing because dirty leaves must be supplied to the virtual hasher in ascending path order. This limits how much work can be done in parallel during reconnect, especially in the common production case where the teacher has more leaves than the learner and the trees also contain modified leaves.
After the root response is received, the learner knows the teacher’s target leaf path range. At that point, the reconnect work can be viewed as three fundamental operations:
1. **Delete stale learner nodes**
- Delete learner leaves outside the teacher’s `[firstLeafPath, lastLeafPath]` range.
2. **Receive definitely dirty nodes**
- If the teacher has more leaves than the learner, the extra teacher leaf range is known to be dirty.
- These leaves could be requested directly without waiting for normal traversal decisions.
3. **Synchronize the remaining overlapping range**
- Traverse the remaining common range to discover clean vs dirty subtrees/leaves.
Today these operations are not fully independent. In particular, receiving dirty leaves is constrained by the hashing contract that expects leaves in ascending path order, so traversal and leaf ingestion are coupled.
### Proposed experiment
Prototype an alternative reconnect mode where the learner performs these three operations in parallel:
- stale-node deletion,
- direct receipt of definitely dirty nodes,
- traversal-based synchronization of the remaining range.
For the experiment, intentionally decouple leaf receipt order from hashing:
- flush received leaf data directly to disk during reconnect,
- do not compute reconnect hashes incrementally while receiving leaves,
- after all teacher data has been received and the learner has caught up, run hashing as a separate final phase.
The goal is to test whether deferring hashing and allowing more parallelism reduces reconnect wall-clock time compared to the current implementation.
### Motivation
In production, the teacher is typically ahead of the learner, meaning the teacher usually has more leaves, plus modifications in the overlapping portion of the tree. This makes the “definitely dirty” range potentially large and a good candidate for parallel direct transfer.
The key question is whether removing the ascending-leaf-order constraint from the hot reconnect path improves throughput enough to offset the cost of a separate final hashing phase.
Contributor guide
Assessment
This issue has not been assessed yet.