Commit a3118c1
committed
Merge #6996: perf: reduce cs_main lock scope in evodb verify/repair operations
084bb62 chore: clang-format (UdjinM6)
ce506bc perf: reduce cs_main lock scope in evodb verify/repair operations (UdjinM6)
Pull request description:
## Issue being fixed or feature implemented
Previously, evodb_verify_or_repair_impl held cs_main for the entire operation, which could take minutes when verifying/repairing large block ranges. This caused significant lock contention and blocked other operations requiring cs_main.
This commit reduces the cs_main lock scope to only the initial setup phase where we resolve block indexes from the active chain. The actual verification and repair work (applying diffs, rebuilding lists from blocks, verifying snapshots) now runs without holding cs_main.
## What was done?
Changes:
- Wrap block index resolution in a scoped cs_main lock
- Remove AssertLockHeld(cs_main) from helper functions:
* RecalculateAndRepairDiffs
* CollectSnapshotBlocks
* VerifySnapshotPair
* RepairSnapshotPair
* RebuildListFromBlock (CSpecialTxProcessor)
- Update function signatures to remove EXCLUSIVE_LOCKS_REQUIRED(cs_main)
## How Has This Been Tested?
Run evodb verify/repair on a mainnet node and monitor logs - it keeps processing other stuff while rpc command is still running.
## Breaking Changes
This is safe because:
- CBlockIndex pointers remain valid after lock release (never deleted)
- Block parent relationships (pprev, GetAncestor) are immutable
- ReadBlockFromDisk takes cs_main internally when accessing nFile/nDataPos
- Helper functions only process already-loaded block data and snapshots
- ChainLocks prevent deep reorgs in Dash anyway
## Checklist:
- [ ] 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:
kwvg:
utACK 084bb62
knst:
utACK 084bb62
Tree-SHA512: aa0db93133767cc6de897d2989c35f00d1cd0506c51463a86cb76cbbe51ea8be5372efb9dbc16791992d8128bc26812e075d13c30c396f97f22198e9611e75dcFile tree
5 files changed
+40
-52
lines changed- src
- evo
- rpc
5 files changed
+40
-52
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1586 | 1586 | | |
1587 | 1587 | | |
1588 | 1588 | | |
1589 | | - | |
1590 | | - | |
1591 | 1589 | | |
1592 | 1590 | | |
1593 | 1591 | | |
| |||
1696 | 1694 | | |
1697 | 1695 | | |
1698 | 1696 | | |
1699 | | - | |
1700 | | - | |
1701 | 1697 | | |
1702 | 1698 | | |
1703 | 1699 | | |
| |||
1749 | 1745 | | |
1750 | 1746 | | |
1751 | 1747 | | |
1752 | | - | |
1753 | | - | |
1754 | 1748 | | |
1755 | 1749 | | |
1756 | 1750 | | |
| |||
1795 | 1789 | | |
1796 | 1790 | | |
1797 | 1791 | | |
1798 | | - | |
1799 | | - | |
1800 | 1792 | | |
1801 | 1793 | | |
1802 | 1794 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
740 | 740 | | |
741 | 741 | | |
742 | 742 | | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
762 | 762 | | |
763 | 763 | | |
764 | | - | |
765 | | - | |
| 764 | + | |
766 | 765 | | |
767 | 766 | | |
768 | 767 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
190 | 188 | | |
191 | 189 | | |
192 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 85 | + | |
| 86 | + | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1760 | 1760 | | |
1761 | 1761 | | |
1762 | 1762 | | |
1763 | | - | |
1764 | | - | |
1765 | 1763 | | |
1766 | 1764 | | |
1767 | 1765 | | |
1768 | | - | |
1769 | | - | |
1770 | | - | |
1771 | | - | |
1772 | | - | |
1773 | | - | |
1774 | | - | |
1775 | | - | |
1776 | | - | |
1777 | | - | |
1778 | | - | |
1779 | | - | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
1780 | 1781 | | |
1781 | | - | |
1782 | 1782 | | |
1783 | | - | |
1784 | | - | |
1785 | | - | |
1786 | | - | |
1787 | | - | |
1788 | | - | |
1789 | | - | |
1790 | | - | |
1791 | | - | |
1792 | | - | |
1793 | | - | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
1794 | 1795 | | |
1795 | 1796 | | |
1796 | 1797 | | |
| |||
1802 | 1803 | | |
1803 | 1804 | | |
1804 | 1805 | | |
1805 | | - | |
1806 | | - | |
| 1806 | + | |
1807 | 1807 | | |
1808 | 1808 | | |
1809 | 1809 | | |
1810 | | - | |
| 1810 | + | |
1811 | 1811 | | |
1812 | 1812 | | |
1813 | 1813 | | |
| |||
0 commit comments