Files
lnd/peer/drop_predicate_integration.go
Olaoluwa Osuntokun f59fa7477d peer: add RED and protected types to msgStream queue
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.
2025-05-19 17:25:54 -07:00

18 lines
441 B
Go

//go:build integration
package peer
import (
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/queue"
)
// getMsgStreamDropPredicate returns the drop predicate for the msgStream's
// BackpressureQueue. For integration builds, this predicate never drops
// messages.
func getMsgStreamDropPredicate() queue.DropPredicate[lnwire.Message] {
return func(queueLen int, item lnwire.Message) bool {
return false
}
}