Commit cab298a
Merge dashpay#6658: perf: cache block data for CreditPool for asset unlock limits calculation
72cfb93 feat: bail out if GetTxPayload failed (Konstantin Akimov)
095b2d8 refactor: use if statement feature (Konstantin Akimov)
9c5e451 fix: typo in error message for GetDataFromUnlockTx (Konstantin Akimov)
52ae3aa refactor: use CreditPoolPeriodBlocks for block_data_cache (Konstantin Akimov)
34e06ec fmt: apply clang-format suggestions (Konstantin Akimov)
1706270 perf: cache block data for credit pool for calculation asset unlock limits (Konstantin Akimov)
e3d3783 refactor: combine GetDataFromUnlockTxes and GetBlockForCreditPool to GetCreditDataFromBlock (Konstantin Akimov)
afd7f84 perf: use GetAncestor() to jump blocks back for CreditPool (Konstantin Akimov)
f7749db refactor: use helper GetDataFromUnlockTxes to get credit pool amount (Konstantin Akimov)
Pull request description:
## Issue being fixed or feature implemented
For each new block CreditPool read blocks twice from disk: for last connected block and for distant block (576 block ago) which is used to calculate sliding window limit for withdrawals.
## What was done?
Added mini cache with block data (locked amount, indexes) to avoid reading block with ReadBlockFromDisk.
[It is possible](https://github.com/knst/dash/tree/perf-cp-cache-2) to avoid 2nd block reading too (for tip), but benchmark doesn't show clear improvement. It will go to the separate PR later.
## How Has This Been Tested?
develop:
<img width="613" alt="image" src="https://github.com/user-attachments/assets/b29382cf-2de3-4223-a85e-2623982ff86a" />
```
2025-05-04T18:36:29Z [bench] - ProcessSpecialTxsInBlock: 52.94ms [84.66s (14.46ms/blk)]
2025-05-04T18:36:29Z [bench] - CheckCreditPoolDiffForBlock: 0.21ms [2.11s (0.36ms/blk)]
2025-05-04T18:36:29Z [bench] - Connect total: 54.40ms [94.48s (16.14ms/blk)]
```
RP:
<img width="613" alt="image" src="https://github.com/user-attachments/assets/40166b85-cc37-4bf3-a618-2931c3d0fdca" />
```
2025-05-05T10:11:47Z [bench] - ProcessSpecialTxsInBlock: 52.62ms [83.01s (14.18ms/blk)]
2025-05-05T10:11:47Z [bench] - CheckCreditPoolDiffForBlock: 0.21ms [2.09s (0.36ms/blk)]
2025-05-05T10:11:47Z [bench] - Connect total: 53.46ms [90.66s (15.49ms/blk)]
```
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] 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:
PastaPastaPasta:
utACK 72cfb93
UdjinM6:
utACK 72cfb93
Tree-SHA512: fd67770d42ed5c8b8d9a9fd542ae632d7ef425e8530902fa033310bc0da18b824e1c35b39c73daa99a480d83aef13ff709b19794c7aa7aa9f2f09d88f6b9ca6c1 parent c596267 commit cab298a
1 file changed
+56
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
60 | 78 | | |
61 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
62 | 92 | | |
63 | 93 | | |
64 | 94 | | |
65 | 95 | | |
66 | 96 | | |
67 | 97 | | |
68 | | - | |
| 98 | + | |
69 | 99 | | |
70 | 100 | | |
71 | 101 | | |
72 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
73 | 106 | | |
74 | 107 | | |
75 | 108 | | |
| |||
112 | 145 | | |
113 | 146 | | |
114 | 147 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 148 | | |
137 | 149 | | |
138 | 150 | | |
139 | | - | |
140 | | - | |
| 151 | + | |
| 152 | + | |
141 | 153 | | |
142 | 154 | | |
143 | 155 | | |
| |||
151 | 163 | | |
152 | 164 | | |
153 | 165 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
166 | | - | |
167 | 172 | | |
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 177 | + | |
| 178 | + | |
177 | 179 | | |
178 | 180 | | |
179 | | - | |
180 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
184 | | - | |
| 187 | + | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
191 | | - | |
| 194 | + | |
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
197 | | - | |
| 200 | + | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
201 | | - | |
202 | | - | |
| 204 | + | |
| 205 | + | |
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
210 | | - | |
| 213 | + | |
211 | 214 | | |
212 | 215 | | |
213 | 216 | | |
| |||
0 commit comments