Skip to content

Conversation

@PastaPastaPasta
Copy link
Member

Issue being fixed or feature implemented

If we are able to get this merged, I'll probably try to upstream this.

m_nodes_mutex is heavily contended; likely more-so in dash than bitcoin, due to master nodes aggressively sending out signature shares and related messages, and additional logic that uses stuff like ForEachNode.

Long term, I may want to convert the non-recursive mutex into a shared mutex, similar to the logic in 6468 as m_nodes is only actually mutated (hence needing an exclusive lock) when nodes are added or removed. CNode is internally thread safe.

As you can see below, m_nodes_mutex represents ~90% of all contention on ~latest nightly on testnet during tx/islock spamming. Making this into a non-recursive mutex will likely significantly reduce the time a contention takes, although, the contention itself likely won't go away.

image

What was done?

Convert m_nodes_mutex from RecursiveMutex -> Mutex and fix all compilation errors.

How Has This Been Tested?

This should be tested with a tsan reindex and otherwise tsan test suite, which has not been done yet.

Breaking Changes

N/a

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)

@PastaPastaPasta PastaPastaPasta added this to the 22.1 milestone Dec 9, 2024
@github-actions
Copy link

github-actions bot commented Dec 9, 2024

This pull request has conflicts, please rebase.

@PastaPastaPasta PastaPastaPasta force-pushed the perf-m_nodes_mutex-non-recursive branch from 32a7a8c to fb561ef Compare December 9, 2024 21:22
@UdjinM6
Copy link

UdjinM6 commented Dec 11, 2024

CI is pretty unhappy...

@PastaPastaPasta
Copy link
Member Author

I had changes that fixed this, but they're on my dead system... will have to wait a week or so before I can recover them.

@PastaPastaPasta PastaPastaPasta marked this pull request as draft December 15, 2024 18:13
@github-actions
Copy link

This pull request has conflicts, please rebase.

@DashCoreAutoGuix
Copy link

ℹ️ Backport Verification - Not Applicable

This PR is not a Bitcoin Core backport and therefore does not require backport verification.

Analysis Results:

  • Original Bitcoin commit: Not applicable (original Dash change)
  • Reviewed commit hash: fb561ef-verify-1753727727
  • PR Type: Original Dash performance improvement to m_nodes_mutex

Summary:
PR #6473 is an original Dash Core change focused on converting m_nodes_mutex from a recursive to non-recursive mutex for performance improvements. This type of change should follow the standard Dash Core review process rather than the Bitcoin backport verification workflow.

The backport verification system is designed exclusively for Bitcoin Core backports to Dash Core. Original Dash changes should be reviewed by the Dash Core development team using the standard review process.

Recommendation: Continue with standard Dash Core review process.

@PastaPastaPasta
Copy link
Member Author

superseded by: #6912

@UdjinM6 UdjinM6 removed this from the 22.1 milestone Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants