Skip to content

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

Merged
lolyu merged 2 commits into
sonic-net:masterfrom
DendroLabs:link-event-damping/selectables-tracker
Jun 6, 2026
Merged

[Link Event Damping] Add SelectablesTracker for timer management#1798
lolyu merged 2 commits into
sonic-net:masterfrom
DendroLabs:link-event-damping/selectables-tracker

Conversation

@DendroLabs

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Collaborator

/azp run

@linux-foundation-easycla

linux-foundation-easycla Bot commented Mar 17, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@DendroLabs

Copy link
Copy Markdown
Contributor Author

/easycla

@mikeberesford mikeberesford left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up

@DendroLabs

Copy link
Copy Markdown
Contributor Author

Hi @kcudnik — friendly ping on this PR. It's been up for about 3 weeks now with CI green and an approval from @mikeberesford.

This is part of a 3-PR set for the link event damping feature:

All three are passing CI. Would appreciate a review when you get a chance. Happy to address any feedback. Thanks!

@lolyu

lolyu commented May 29, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

5 participants