Skip to content
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

P2P: improve RX/TX flow control #2017

Closed
wants to merge 2 commits into from
Closed

Conversation

jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Nov 15, 2012

  • "optimistic write": Push each message to kernel socket buffer immediately
  • If there is write data at select time, that implies send() blocked during optimistic write. Drain write queue, before receiving any more messages.

This avoids needlessly queueing received data, if the remote peer is not themselves receiving data.

Result: write buffer (and thus memory usage) is kept small, DoS potential is slightly lower, and TCP flow control signalling is properly utilized.

The kernel will queue data into the socket buffer, then signal the remote peer to stop sending data, until we resume reading again.

Jeff Garzik added 2 commits November 15, 2012 18:04
1) "optimistic write": Push each message to kernel socket buffer immediately.

2) If there is write data at select time, that implies send() blocked
   during optimistic write.  Drain write queue, before receiving
   any more messages.

This avoids needlessly queueing received data, if the remote peer
is not themselves receiving data.

Result: write buffer (and thus memory usage) is kept small, DoS
potential is slightly lower, and TCP flow control signalling is
properly utilized.

The kernel will queue data into the socket buffer, then signal the
remote peer to stop sending data, until we resume reading again.
if (lockSend && !pnode->vSend.empty())
FD_SET(pnode->hSocket, &fdsetSend);
if (lockSend) {
// do not read, if draining write queue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part. Why make fdsetRecv depend on the state of the write queue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laanwj That is explained in the commit message / pull request message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But future readers of the code won't see your commit message. They need comments to understand what's going on.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/4e4e6d1feca92c346389d4221d022db8f8cd3e78 for binaries and test log.

@sipa
Copy link
Member

sipa commented Feb 24, 2013

@jgarzik @gavinandresen I'd like to see this in 0.8.1.

@sipa sipa mentioned this pull request Mar 24, 2013
@jgarzik
Copy link
Contributor Author

jgarzik commented Mar 24, 2013

Superceded by #2409

@jgarzik jgarzik closed this Mar 24, 2013
@jgarzik jgarzik deleted the tx-full branch August 24, 2014 04:19
KolbyML pushed a commit to KolbyML/bitcoin that referenced this pull request Dec 5, 2020
1c43a1e GUI: Do not try to create a shielded address or process a shielded spend if v5 upgrade hasn't been enforced yet. (furszy)

Pull request description:

  Visual notification, do not try to create shielded addresses or process shielded spends if v5 upgrade hasn't been enforced yet.

ACKs for top commit:
  random-zebra:
    utACK 1c43a1e
  Fuzzbawls:
    ACK 1c43a1e

Tree-SHA512: 22bbbc1cb3c485c67ba204c59421cbf4970ebb97d50bb25feabb5e6e77697ee2de93837982d345ef698ba4663142cdda306d2988eefd8c5c3eb0e363beb09ae8
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants