Commit ce506bc
committed
perf: reduce cs_main lock scope in evodb verify/repair operations
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.
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)
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 anyway1 parent 86e84d7 commit ce506bc
File tree
5 files changed
+34
-47
lines changed- src
- evo
- rpc
5 files changed
+34
-47
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 | |
|---|---|---|---|
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
746 | | - | |
| 746 | + | |
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
758 | | - | |
| 758 | + | |
759 | 759 | | |
760 | | - | |
761 | | - | |
| 760 | + | |
762 | 761 | | |
763 | 762 | | |
764 | | - | |
765 | | - | |
| 763 | + | |
766 | 764 | | |
767 | 765 | | |
768 | 766 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 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