queue: add new BackpressureQueue[T] variant#9838
Conversation
|
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:
|
gijswijs
left a comment
There was a problem hiding this comment.
I did a pass of this and made a bunch of comments. There seems to be a lot of LLM fluff (although I could be mistaken) that I don't like.
2e346d0 to
3511604
Compare
|
Pushed up a new version. PTAL. |
gijswijs
left a comment
There was a problem hiding this comment.
Did a second pass. Mainly nits (line length! 😄) and some clarifications from my side about the use of generics in the tests.
Suffice to say that I really like this. I already used it in #10219 so I would love to see this merged.
@yyforyongyu Could you have a go at this as well?
| } | ||
|
|
||
| // intQueueMachine is a concrete wrapper for queueMachine[int] for rapid. | ||
| type intQueueMachine struct { |
There was a problem hiding this comment.
No, I meant
type intQueueMachine struct {
tb rapid.TB
capacity int
queue *BackpressureQueue[int]
modelQueue []int
dropPredicate DropPredicate[int]
itemGenerator *rapid.Generator[int]
}
and take it from there.
| } | ||
|
|
||
| // intQueueMachine is a concrete wrapper for queueMachine[int] for rapid. | ||
| type intQueueMachine struct { |
There was a problem hiding this comment.
This is what copilot came up with. Github doesn't allow me to upload .diff files, hence the .txt extension. no-generics.txt
3511604 to
3998b98
Compare
gijswijs
left a comment
There was a problem hiding this comment.
Some minor issues still, mostly validation and better comments. I don't think release notes are in place here, so maybe add the no-changelog label to the PR to skip that CI check.
|
As I'm building on top of this in my onion messaging branch I made a few changes to the commit from this PR. Wanted to flag them in case you'd like to incorporate any of these upstream. Split
New methods on
Minor behavioral change:
Better RED comment:
Tests:
This is the amended commit |
3998b98 to
5759675
Compare
|
Thanks for putting that together! Incorporated most of these changes in the latest push:
|
In this commit, we add a new type of queue: the back pressure queue. This is a bounded queue based on a simple channel, that will consult a predicate to decide if we should preemptively drop a message or not. We then provide a sample predicate for this use case, based on random early dropping. Given a min and max threshold, we'll start to drop message randomly once we get past the min threshold, ramping up to the max threshold where we'll start to always drop the message.
0379b2d to
8cef46e
Compare
|
@gijswijs: review reminder |
|
Folded into 6b806f2 |
In this commit, we add a new type of queue: the back pressure queue. This is a bounded queue based on a simple channel, that will consult a predicate to decide if we should preemptively drop a message or not.
We then provide a sample predicate for this use case, based on random early dropping. Given a min and max threshold, we'll start to drop message randomly once we get past the min threshold, ramping up to the max threshold where we'll start to always drop the message.