Net: Pass MSG_MORE flag when sending non-final network messages #12519

pull whitslack wants to merge 1 commits into bitcoin:master from whitslack:MSG_MORE changing 1 files +7 −1
  1. whitslack commented at 7:35 PM on February 23, 2018: contributor

    Since Nagle's algorithm is disabled, each and every call to send(2) can potentially generate a separate TCP segment on the wire. This is especially inefficient when sending the tiny header preceding each message payload.

    Linux implements a MSG_MORE flag that tells the kernel not to push the passed data immediately to the connected peer but rather to collect it in the socket's internal transmit buffer where it can be combined with data from successive calls to send(2). Where available, specify this flag when calling send(2) in CConnman::SocketSendData(CNode *) if the data buffer being sent is not the last one in pnode->vSendMsg.

  2. Pass MSG_MORE flag when sending non-final network messages
    Since Nagle's algorithm is disabled, each and every call to send(2) can potentially generate a separate TCP segment on the wire. This is especially inefficient when sending the tiny header preceding each message payload.
    
    Linux implements a MSG_MORE flag that tells the kernel not to push the passed data immediately to the connected peer but rather to collect it in the socket's internal transmit buffer where it can be combined with data from successive calls to send(2). Where available, specify this flag when calling send(2) in CConnman::SocketSendData(CNode *) if the data buffer being sent is not the last one in pnode->vSendMsg.
    676d48fc20
  3. theuni commented at 7:42 PM on February 23, 2018: member

    I'd rather not, as we'll be switching to sendmsg soon, instead taking advantage of scatter/gather which is highly preferable as it only requires one syscall. I've implemented this here: https://github.com/bitcoin/bitcoin/pull/11227/commits/77cee166e17e355306d2ca1a1d360e71c12d8350 as part of #11227. It may make sense to go ahead and take that change rather than waiting for all of the other libevent changes to go in first.

    Note that something like TCP_CORK may still be useful, though, in the event that more than 1 sendmsg would be required.

  4. fanquake added the label P2P on Feb 23, 2018
  5. laanwj commented at 9:18 PM on March 6, 2018: member

    Thanks for the contribution, but I agree it'd be better to not change this in the mean time until @theuni's change (hopefully soon) will go in.

  6. laanwj closed this on Mar 6, 2018

  7. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 12:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me