Skip to content

[Link Event Damping] Add SelectablesTracker for timer management#1798

Open
DendroLabs wants to merge 2 commits intosonic-net:masterfrom
DendroLabs:link-event-damping/selectables-tracker
Open

[Link Event Damping] Add SelectablesTracker for timer management#1798
DendroLabs wants to merge 2 commits intosonic-net:masterfrom
DendroLabs:link-event-damping/selectables-tracker

Conversation

@DendroLabs
Copy link

Summary

Supersedes #1323 by @Ashish1805. Adds the SelectablesTracker class for tracking selectable timers used by the link event damper in syncd.

This is part of the Link Event Damping feature (HLD: sonic-net/SONiC#1071).

All review feedback from #1323 has been addressed:

  • Moved class members to private (@kcudnik)
  • Replaced raw pointers with shared_ptr for memory safety (@kcudnik)
  • Fixed code ordering -- null checks before getFd() call (@Junchao-Mellanox)
  • Added empty line before if() blocks (@kcudnik)
  • CodeQL constexpr fix already present on master

Changes:

  • syncd/SelectablesTracker.h -- Header with private members, shared_ptr interface
  • syncd/SelectablesTracker.cpp -- Implementation with proper null checking order
  • unittest/syncd/TestSelectablesTracker.cpp -- 11 unit test cases
  • unittest/syncd/MockSelectablesTracker.h -- Mock class in separate file
  • Build integration in both syncd/Makefile.am and unittest/syncd/Makefile.am

Dependency chain: This PR is a prerequisite for the per-port link event damper (#1334) and the libsai RedisInterface (#1331).

Test plan

  • 11 new unit tests covering add/remove/get operations, null handling, duplicate detection
  • Existing syncd unit tests pass (no regressions)
  • Azure Pipelines CI green

🤖 Generated with Claude Code

Co-Authored-By: Ashish Singh ashish.singh@google.com

@mssonicbld
Copy link
Collaborator

/azp run

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 17, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

…king

Supersedes PR sonic-net#1323 by @Ashish1805. Adds SelectablesTracker class that
tracks Selectable objects and their corresponding EventHandler mappings,
used by the link event damper feature.

Changes from original PR addressing review feedback:
- Move non-copyable/non-movable declarations to private section (@kcudnik)
- Replace raw pointers with shared_ptr for EventHandler to prevent memory
  leaks, consistent with syncd project conventions (@kcudnik)
- Reorder null checks: check eventHandler before accessing selectable fd
  (@Junchao-Mellanox)
- Add empty line before if() for consistent formatting (@kcudnik)

Signed-off-by: DendroLabs <info@dendrolabs.com>
- Add std::mutex thread synchronization to all public methods
- Add missing mock methods (selectableIsTracked, getEventHandlerForSelectable)
- Fix test use-after-free by adding TearDown cleanup
- Add const qualifiers to read-only methods

Signed-off-by: DendroLabs <info@dendrolabs.com>
@DendroLabs DendroLabs force-pushed the link-event-damping/selectables-tracker branch from 1f19657 to dacab2c Compare March 17, 2026 15:56
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DendroLabs
Copy link
Author

/easycla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants