You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #6719: perf: parse CbTx only once perf block
0c7cfd9 refactor: make CheckCreditPoolDiffForBlock private and tidy up it (Konstantin Akimov)
a7fe377 refactor: bench time is properly aligned, variables properly renamed (Konstantin Akimov)
ebb9dc0 perf: parse CCbTx once during block validation for Credit Poool (Konstantin Akimov)
59c2407 refactor: remove ProcessSpecialTx and UndoSpecialTx which do nothing (Konstantin Akimov)
60bf96d perf: exclude parsing CCbTx if flag fCheckCbTxMerkleRoots is not set (Konstantin Akimov)
b911929 perf: parse CCbTx once during block validation (check CbTx) (Konstantin Akimov)
d4f4173 perf: parse CCbTx once during block validation (merkle roots and CL) (Konstantin Akimov)
Pull request description:
## Issue being fixed or feature implemented
Coinbase Transaction (CCbTx) is parsed several times:
- itself validation (during CheckCbTx)
- for merkle roots (during CheckCbTxMerkleRoots)
- for CL validation (during CheckCbTxBestChainlock)
- for Credit Pool (during CheckCreditPoolDiffForBlock)
For pre-v20 blocks this parsing has been relatively cheap, but once V20 has been activated, each CbTx has CL signature and its deserialization become expensive due to heavy call of `CBLSWrapper<bls::G2Element, 96ul, CBLSSignature>::Unserialize<CDataStream>(CDataStream&, bool)`.
## What was done?
CCbTx is parsed only once and reused for all related checks.
This PR makes validation of blocks after v20 activation for ~6% faster.
Validation of pre-v20 block is expected to be improved insignificantly (<1% of total time).
## How Has This Been Tested?
Invalidated + reconsidered ~8.5k blocks (~2 weeks) after v20 activation.
Develop:
<img width="704" alt="image" src="https://github.com/user-attachments/assets/08b63507-4cbf-4e2c-917e-1287ff17210d" />
```
[bench] - Loop: 0.22ms [10.01s]
[bench] - GetTxPayload: 0.21ms [2.16s]
[bench] - CheckCbTxMerkleRoots: 3.23ms [28.46s]
[bench] - CheckCbTxBestChainlock: 3.16ms [24.65s]
[bench] - ProcessSpecialTxsInBlock: 8.15ms [101.19s (11.66ms/blk)]
[bench] - CheckCreditPoolDiffForBlock: 0.22ms [2.98s (0.34ms/blk)]
[bench] - Dash specific: 0.42ms [4.98s (0.57ms/blk)]
[bench] - Connect total: 8.87ms [113.20s (13.04ms/blk)]
[bench] - Connect block: 9.26ms [116.51s (13.42ms/blk)]
```
PR:
<img width="704" alt="image" src="https://github.com/user-attachments/assets/697d9b73-83f4-419e-9ecc-fa9c24e1eafc" />
```
[bench] - GetTxPayload: 0.24ms [2.34s]
[bench] - Loop: 0.02ms [7.89s]
[bench] - CheckCreditPoolDiffForBlock: 0.01ms [0.76s]
[bench] - CheckCbTxMerkleRoots: 3.17ms [26.50s]
[bench] - CheckCbTxBestChainlock: 3.08ms [22.77s]
[bench] - ProcessSpecialTxsInBlock: 8.02ms [98.70s (11.37ms/blk)]
[bench] - Dash specific: 0.27ms [1.97s (0.23ms/blk)]
[bench] - Connect total: 8.58ms [107.65s (12.40ms/blk)]
[bench] - Connect block: 8.92ms [110.97s (12.78ms/blk)]
```
Some insignificant lines (not relevant to PR) are removed from both screenshots and bench logs, only affected functions are shown.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
ACKs for top commit:
UdjinM6:
utACK 0c7cfd9
PastaPastaPasta:
utACK 0c7cfd9
Tree-SHA512: b684f8b3073870ac40cb4de19066e9424307e2c39c753e0bc3c584d491c8dbc1634a35b63fe906acfe03bf9e1b78f0642cee4c0c3715533570ea6693fa4767ea
0 commit comments