Skip to content

Commit

Permalink
Merge #6424: refactor: move expensive CInv initialization out of hot …
Browse files Browse the repository at this point in the history
…loop

b65f0ba refactor: move expensive CInv initialization out of hot loop (pasta)

Pull request description:

  ## 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:
  - [x] 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
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  knst:
    utACK b65f0ba
  UdjinM6:
    utACK b65f0ba
  kwvg:
    utACK b65f0ba

Tree-SHA512: f556789042ab9265d5c4d87c3ba2910138ce43ffa69c90ed208c9a3bcd861343f201ce2f00aeb541f345c9ca686dac7227df8d4833cf7fbdf61c36260f627864
  • Loading branch information
PastaPastaPasta committed Nov 22, 2024
2 parents f77e381 + b65f0ba commit 0398b1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
LOCK(m_peer_mutex);
for(auto& it : m_peer_map) {
Peer& peer = *it.second;
auto tx_relay = peer.GetTxRelay();
if (!tx_relay) continue;

const CInv inv{m_cj_ctx->dstxman->GetDSTX(txid) ? MSG_DSTX : MSG_TX, txid};
PushInv(peer, inv);
};
}
Expand Down

0 comments on commit 0398b1c

Please sign in to comment.