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 #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: 1ea45e92c717dbefe5625bba3b27612b9ffbb21ea106d11005d78836fbe6ce00503e3f3fdb927fb405b09fd795f50137ca2beb07351bf94488d2af5694e543ba
// Let's see if the TX that was locked by this islock is already mined in a ChainLocked block. If yes,
155
160
// we can simply ignore the islock, as the ChainLock implies locking of all TXs in that chain
156
-
if (pindexMined != nullptr && clhandler.HasChainLock(pindexMined->nHeight, pindexMined->GetBlockHash())) {
157
-
LogPrint(BCLog::INSTANTSEND, "CInstantSendManager::%s -- txlock=%s, islock=%s: dropping islock as it already got a ChainLock in block %s, peer=%d\n", __func__,
0 commit comments