-
Notifications
You must be signed in to change notification settings - Fork 2.2k
peer: replace the old cond based msgStream w/ BackpressureQueue[T] #9839
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
base: backpressure-queue
Are you sure you want to change the base?
Conversation
In this commit, we replace the old condition variable based msgStream with the new back pressure queue. The implementation details at this abstraction level have been greatly simplified. For now we just pass a predicate that'll never drop the incoming packets.
The msgStream's backpressure queue previously used a drop predicate that always returned false, meaning messages were never dropped based on queue length. This commit introduces a new drop predicate mechanism for the msgStream queue, controlled by build tags. For non-integration builds, the predicate combines a type-based check with Random Early Detection (RED): - Certain critical message types (`lnwire.LinkUpdater`, `lnwire.AnnounceSignatures1`) are marked as protected and are never dropped. - For other message types, RED is applied based on the queue length, using `redMinThreshold` and `redMaxThreshold` to determine the drop probability. For integration builds, the predicate always returns false, preserving the previous behavior to avoid interfering with tests. This change allows the msgStream queue to proactively drop less critical messages under high load, preventing unbounded queue growth while ensuring essential messages are prioritized.
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Pull reviewers statsStats of the last 30 days for lnd:
|
In this commit, we replace the old condition variable based msgStream
with the new back pressure queue. The implementation details at this
abstraction level have been greatly simplified. For now we just pass a
predicate that'll never drop the incoming packets.
In a follow up commit, we then start to actually set a predicate to decide
when to drop incoming packets. We use two layers of predicates:
always dropping packets up to some other max threshold.
This is mostly a draft of some ideas I was kicking around the other day.
One other scenario to consider is: initial graph download. IGD well end up
sending 10s of thousands of messages to a remote peer so they can sync
to the graph. As is, we'll start to drop some of those messages if we aren't
able to process them quickly enough (unless the remote peer has implemented
a form of application-level flow control).
To patch that gap, we could consider never dropping if we're doing an IGD or
graph spot check with a peer. We can consult the gossip syncer for a given
peer to decide if we should drop or not (outside the protected set).
Initial Params
The Random Early Drop algo added takes two params: a min threshold,
and a max threshold. Here's a table that contains the probability of drop
with a queue size of 50, and two diff params for min+max threshold: