Commit 1ab7e9e
committed
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: b684f8b3073870ac40cb4de19066e9424307e2c39c753e0bc3c584d491c8dbc1634a35b63fe906acfe03bf9e1b78f0642cee4c0c3715533570ea6693fa4767eaFile tree
5 files changed
+129
-188
lines changed- src
- evo
5 files changed
+129
-188
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 24 | | |
39 | 25 | | |
40 | 26 | | |
| |||
59 | 45 | | |
60 | 46 | | |
61 | 47 | | |
62 | | - | |
| 48 | + | |
63 | 49 | | |
64 | 50 | | |
65 | 51 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 52 | | |
84 | 53 | | |
85 | 54 | | |
86 | 55 | | |
| 56 | + | |
87 | 57 | | |
88 | 58 | | |
89 | 59 | | |
| |||
93 | 63 | | |
94 | 64 | | |
95 | 65 | | |
96 | | - | |
97 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
98 | 70 | | |
99 | 71 | | |
100 | 72 | | |
| |||
106 | 78 | | |
107 | 79 | | |
108 | 80 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
112 | 85 | | |
113 | 86 | | |
114 | 87 | | |
| |||
314 | 287 | | |
315 | 288 | | |
316 | 289 | | |
317 | | - | |
| 290 | + | |
318 | 291 | | |
319 | 292 | | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | 293 | | |
331 | 294 | | |
332 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
0 commit comments