-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Conversation
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 |
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.
I don't understand this part. Why make fdsetRecv depend on the state of the write queue?
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.
@laanwj That is explained in the commit message / pull request message.
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.
But future readers of the code won't see your commit message. They need comments to understand what's going on.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/4e4e6d1feca92c346389d4221d022db8f8cd3e78 for binaries and test log. |
@jgarzik @gavinandresen I'd like to see this in 0.8.1. |
Superceded by #2409 |
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
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.