-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[discovery] Isolate gossip rate limiting #2135
[discovery] Isolate gossip rate limiting #2135
Conversation
This commit restructures the delivery of gossip query related messages, such that they are delivered directly to the gossip syncers. Gossip query rate limiting was introduced in lightningnetwork#1824 on a per-peer basis. However, since all gossip query messages were being delivered in the main event loop, the end result is that one rate-limited peer could stall all other peers. In addition, since no other peers would be able to submit gossip-related messages through the blocked event loop, the back pressure would eventually rate limit the read handlers of all peers as well. The end result would be lengthy delays in reading messages related to htlc forwarding. The fix is to lift the delivery of gossip query messages outside of the main event loop. With this change, the rate limiting backpressure is delivered only to the intended peer.
This commit passes the peer's quit signal to the gossipSyncer when attempt to hand off gossip query messages. This allows a rate-limited peer's read handler to break out immediately, which would otherwise remain stuck until the rate-limited gossip syncer pulled the message.
// For messages in the known set of channel series queries, we'll | ||
// dispatch the message directly to the gossipSyncer, and skip the main | ||
// processing loop. | ||
switch m := msg.(type) { |
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 would be more confident in this change if we instead created a separate event loop for gossip query messages that we handed them off to.
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.
If they all go through one event loop then we’re back to square one. Are you suggesting one event loop per gossip syncer?
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 was thinking one event loop per peer, but I see now that that might get very complex 🤔
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.
Yeah in some sense this change already has one event loop per peer (the readHandler) and the back pressure is now applied there directly
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.
LGTM 👾
Testing this now on the faucet, will merge in the next day or so if everything goes smoothly.
No description provided.