[PR #5227] [CLOSED] [management] Add gRPC update debouncing mechanism #22437

Open
opened 2026-08-05 06:05:57 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5227
Author: @pappz
Created: 1/31/2026
Status: Closed

Base: mainHead: feature/grpc-debounce


📝 Commits (2)

  • 2111a34 Add gRPC update debouncing mechanism
  • debe65e Enhance unit test to verify peer count synchronization with debouncing and timeout handling

📊 Changes

4 files changed (+525 additions, -7 deletions)

View changed files

📝 management/internals/shared/grpc/server.go (+27 -1)
management/internals/shared/grpc/update_debouncer.go (+95 -0)
management/internals/shared/grpc/update_debouncer_test.go (+350 -0)
📝 management/server/management_test.go (+53 -6)

📄 Description

Implements backpressure handling for peer network map updates to efficiently handle rapid changes. The first update is sent immediately; subsequent rapid updates are coalesced, ensuring that only the latest update is sent after a 1-second quiet period.

Intermediate changes do not need to be applied, so the focus is on processing only the final update in the queue.
This also fixes lost network updates on the producer side. The network map producer should not depend on network-related layers. Todo: set the channal size to 1 and set it to blocker.

Describe your changes

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • Infrastructure

    • Introduced a per-peer update debouncing mechanism to reduce redundant transmissions, improve backpressure and coalesce rapid updates for streaming syncs.
  • Tests

    • Added comprehensive test coverage verifying immediate send behavior, coalescing of rapid updates, timer-driven flushes, cleanup, and various edge cases.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5227 **Author:** [@pappz](https://github.com/pappz) **Created:** 1/31/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/grpc-debounce` --- ### 📝 Commits (2) - [`2111a34`](https://github.com/netbirdio/netbird/commit/2111a34470b35188096b05c5663075f950f0bbd7) Add gRPC update debouncing mechanism - [`debe65e`](https://github.com/netbirdio/netbird/commit/debe65e01ef193dfb2400ae61440d64ffd7aa8b1) Enhance unit test to verify peer count synchronization with debouncing and timeout handling ### 📊 Changes **4 files changed** (+525 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `management/internals/shared/grpc/server.go` (+27 -1) ➕ `management/internals/shared/grpc/update_debouncer.go` (+95 -0) ➕ `management/internals/shared/grpc/update_debouncer_test.go` (+350 -0) 📝 `management/server/management_test.go` (+53 -6) </details> ### 📄 Description Implements backpressure handling for peer network map updates to efficiently handle rapid changes. The first update is sent immediately; subsequent rapid updates are coalesced, ensuring that only the latest update is sent after a 1-second quiet period. Intermediate changes do not need to be applied, so the focus is on processing only the final update in the queue. This also fixes lost network updates on the producer side. The network map producer should not depend on network-related layers. Todo: set the channal size to 1 and set it to blocker. ## Describe your changes ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Infrastructure** * Introduced a per-peer update debouncing mechanism to reduce redundant transmissions, improve backpressure and coalesce rapid updates for streaming syncs. * **Tests** * Added comprehensive test coverage verifying immediate send behavior, coalescing of rapid updates, timer-driven flushes, cleanup, and various edge cases. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:05:57 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#22437