Allow to disable optimistic send in PushMessage()
Profiling has shown that optimistic send causes measurable slowdowns when many messages are pushed, even if the sockets are non-blocking. Better to allow disabling of optimistic sending in such cases and let the network thread do the actual socket calls.
This commit is contained in:
parent
bedfc262e2
commit
cf29320988
@ -3054,7 +3054,7 @@ bool CConnman::NodeFullyConnected(const CNode* pnode)
|
||||
return pnode && pnode->fSuccessfullyConnected && !pnode->fDisconnect;
|
||||
}
|
||||
|
||||
void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
|
||||
void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg, bool allowOptimisticSend)
|
||||
{
|
||||
size_t nMessageSize = msg.data.size();
|
||||
size_t nTotalSize = nMessageSize + CMessageHeader::HEADER_SIZE;
|
||||
@ -3071,7 +3071,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
|
||||
size_t nBytesSent = 0;
|
||||
{
|
||||
LOCK(pnode->cs_vSend);
|
||||
bool optimisticSend(pnode->vSendMsg.empty());
|
||||
bool optimisticSend(allowOptimisticSend && pnode->vSendMsg.empty());
|
||||
|
||||
//log total amount of bytes per command
|
||||
pnode->mapSendBytesPerMsgCmd[msg.command] += nTotalSize;
|
||||
|
@ -201,7 +201,7 @@ public:
|
||||
|
||||
bool IsMasternodeOrDisconnectRequested(const CService& addr);
|
||||
|
||||
void PushMessage(CNode* pnode, CSerializedNetMsg&& msg);
|
||||
void PushMessage(CNode* pnode, CSerializedNetMsg&& msg, bool allowOptimisticSend = true);
|
||||
|
||||
template<typename Condition, typename Callable>
|
||||
bool ForEachNodeContinueIf(const Condition& cond, Callable&& func)
|
||||
|
Loading…
Reference in New Issue
Block a user