Skip to content

Trickle Gossip Messages #2979

@cfromknecht

Description

@cfromknecht

LND currently constructs a new batch of gossip messages to broadcast every 90s using a trickleTimer in the gossiper. Every time the timer expires, the messages are deduplicated and immediately broadcast to all peers that are receiving updates.

This approach creates needlessly bursty resource usage on both the sending and receiving side, and profiling confirms that this creates punctuated equilibriums in terms of bandwidth/cpu/memory. We can achieve more stable and consistent resource usage by dispersing each newly created batch over the subsequent 90s instead of delivering them all at once.

Steps to completion:

  1. Decide how often the sub-batches should be sent, e.g. 5 seconds
  2. Split an announcement batch into the sub-batches, where the size of each sub-batch should be roughly len(announcementBatch)/numSubBatchesIn90s, bonus points for using slice tricks
  3. Instead of queueing the entire announcmentBatch immediately, spawn a goroutine to perform the remainder of the queueing logic for each sub-batch on the chosen interval. Note that the set of GossipSyncers can change over this period, so the syncers and filtering logic should be evaluated at the time each sub-batch is processed

Additional Considerations:

  • Should we enforce a minimum batch size? If we only have 10 updates to send, do we really want to space each message by 5 seconds?

Metadata

Metadata

Assignees

No one assigned

    Labels

    beginnerIssues suitable for new developersenhancementImprovements to existing features / behaviourfeature requestRequests for new featuresgossipp2pCode related to the peer-to-peer behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions