-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: move expensive CInv initialization out of hot loop #6424
refactor: move expensive CInv initialization out of hot loop #6424
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK b65f0ba
@@ -2328,13 +2328,13 @@ void PeerManagerImpl::RelayInvFiltered(CInv &inv, const uint256& relatedTxHash, | |||
|
|||
void PeerManagerImpl::RelayTransaction(const uint256& txid) | |||
{ | |||
const CInv inv{m_cj_ctx->dstxman->GetDSTX(txid) ? MSG_DSTX : MSG_TX, txid}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually it's only 10-12 peers, so, maybe improvements is non-noticeable by benchmark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, no, not necessarily, MNs are highly connected. As an example on testnet
ubuntu@masternode-12:~$ dash-cli getpeerinfo | jq .[].id | wc -l
100
and only 4 of them have tx relay disabled
ubuntu@masternode-12:~$ dash-cli getpeerinfo | jq .[].relaytxes | grep false | wc -l
4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, I completely forgot about MNs 🫣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, I completely forgot about MNs 🫣
Careful about that, they may fire you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
utACK b65f0ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK b65f0ba
Issue being fixed or feature implemented
Not sure how we introduced this one, but it appears we are calling a CInv construction (pretty cheap) and a GetDSTX ((relatively) EXPENSIVE) for each peer we are connected to in RelayTransaction... I can hope and pray that the compiler somehow was magically optimizing this for us, but I really doubt it
What was done?
Move the initialization out of the loop
How Has This Been Tested?
Breaking Changes
N/A
Checklist: