Commit 23de969
committed
Merge #6953: feat: instantsend cache heights and reduce cs_main contention
e918729 refactor: add CacheTipHeight, improve cache API safety (UdjinM6)
493d077 refactor: simplify optional usage (pasta)
0e1f114 instantsend: cache heights and reduce cs_main contention (pasta)
Pull request description:
## Issue being fixed or feature implemented
Today's testing on testnet showed under load, cs_main was a major contender:
(however, note the major contenders from before #6912 / #6468 are now significantly reduced)
```
========================================================================================================================
TOP 40 LOCATIONS BY TOTAL CONTENTION TIME (AGGREGATE)
========================================================================================================================
Lock Name Location Count Total(μs) Avg(μs) Max(μs) Nodes
------------------------------------------------------------------------------------------------------------------------
cs llmq/signing_shares.cpp:507 11952 81357095 6807.0 299734 8
::cs_main instantsend/signing.cpp:210 75241 62985844 837.1 93240 8
cs_main index/base.cpp:340 29584 27040349 914.0 1613365 8
cs_main net_processing.cpp:5462 69291 19784473 285.5 1329191 8
cs llmq/signing_shares.cpp:1732 2355 17466035 7416.6 127471 8
::cs_main llmq/quorums.cpp:1214 38975 15478543 397.1 883884 8
m_nodes_mutex net.cpp:2043 33457 14736059 440.4 31622 8
::cs_main llmq/quorums.cpp:526 10587 10577503 999.1 2083501 8
pnode->cs_vSend net.cpp:2435 68528 9671050 141.1 37265 8
cs_main net_processing.cpp:4196 4945 8608157 1740.8 1326146 8
::cs_main instantsend/instantsend.cpp:272 5602 8416269 1502.4 1260997 8
cs txmempool.cpp:1319 7942 8059684 1014.8 356199 8
::cs_main validation.cpp:3747 309 6468144 20932.5 1225274 8
::cs_main validation.cpp:6009 21855 3393152 155.3 228195 8
pnode->cs_vSend net.cpp:4709 7532 2299813 305.3 41543 8
m_nodes_mutex ./net.h:1374 6229 1998506 320.8 15593 8
inv_relay->m_tx_inventory_mutex net_processing.cpp:1169 7687 1871859 243.5 16292 8
cs_db instantsend/db.cpp:239 4323 1527297 353.3 20779 8
cs_cache spork.cpp:244 18083 1331472 73.6 27722 8
::cs_main chainlock/signing.cpp:58 98 1312496 13392.8 1273691 8
cs_db ./instantsend/db.h:139 4381 1305738 298.0 29777 8
mutexMsgProc net.cpp:2604 4877 1243737 255.0 24641 8
```
- Add unordered_lru_cache for block heights in CInstantSendManager
- Provide GetTipHeight() (non-optional) and GetBlockHeight() helpers
- Use cache in InstantSendSigner::CheckCanLock
- Cache-first for cycleHash height in ISLOCK message path and batch verify
- Cache-first mined-height for HasChainLock and WriteInstantSendLockMined
## What was done?
## How Has This Been Tested?
## Breaking Changes
_Please describe any breaking changes your code introduces_
## Checklist:
_Go over all the following points, and put an `x` in all the boxes that apply._
- [ ] 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
- [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
ACKs for top commit:
UdjinM6:
utACK e918729
Tree-SHA512: 1ea45e92c717dbefe5625bba3b27612b9ffbb21ea106d11005d78836fbe6ce00503e3f3fdb927fb405b09fd795f50137ca2beb07351bf94488d2af5694e543baFile tree
5 files changed
+149
-38
lines changed- src/instantsend
5 files changed
+149
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | 148 | | |
150 | 149 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
154 | 159 | | |
155 | 160 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
165 | | - | |
166 | | - | |
| 172 | + | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
251 | 258 | | |
252 | 259 | | |
253 | 260 | | |
| 261 | + | |
| 262 | + | |
254 | 263 | | |
255 | 264 | | |
256 | 265 | | |
| |||
278 | 287 | | |
279 | 288 | | |
280 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
281 | 297 | | |
282 | 298 | | |
283 | 299 | | |
| |||
417 | 433 | | |
418 | 434 | | |
419 | 435 | | |
| 436 | + | |
| 437 | + | |
420 | 438 | | |
421 | 439 | | |
422 | 440 | | |
| |||
597 | 615 | | |
598 | 616 | | |
599 | 617 | | |
600 | | - | |
| 618 | + | |
601 | 619 | | |
602 | 620 | | |
603 | 621 | | |
| |||
703 | 721 | | |
704 | 722 | | |
705 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
706 | 782 | | |
707 | 783 | | |
708 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
| |||
122 | 132 | | |
123 | 133 | | |
124 | 134 | | |
125 | | - | |
| 135 | + | |
126 | 136 | | |
127 | 137 | | |
128 | 138 | | |
| |||
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
145 | | - | |
| 155 | + | |
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
149 | | - | |
| 159 | + | |
150 | 160 | | |
151 | | - | |
152 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
153 | 164 | | |
154 | 165 | | |
155 | 166 | | |
| |||
159 | 170 | | |
160 | 171 | | |
161 | 172 | | |
162 | | - | |
| 173 | + | |
163 | 174 | | |
164 | | - | |
| 175 | + | |
| 176 | + | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
168 | 180 | | |
169 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
170 | 187 | | |
171 | 188 | | |
172 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 45 | + | |
| 46 | + | |
48 | 47 | | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
129 | | - | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
213 | 224 | | |
214 | 225 | | |
215 | | - | |
216 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
217 | 229 | | |
218 | 230 | | |
219 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
0 commit comments