[Link Event Damping] Add tracker to track the selectable timers used by link event damper#1323
[Link Event Damping] Add tracker to track the selectable timers used by link event damper#1323Ashish1805 wants to merge 1 commit intosonic-net:masterfrom
Conversation
|
Hi @kcudnik
I am not sure what is the protocol here: do we add fix PR for this or revert the culprit PR #1310 and merge it again with suggested changes? |
SAME ISSUE CAUSES SWSS ERROR HERE: #1310 (comment) please figure out why this is causing build error or revert the change ! |
| virtual bool addSelectableToTracker( | ||
| _In_ swss::Selectable *selectable, | ||
| _In_ SelectableEventHandler *eventHandler); | ||
|
|
||
| // Removes a Selectable from the map. | ||
| virtual bool removeSelectableFromTracker( | ||
| _In_ swss::Selectable *selectable); | ||
|
|
||
| // Checks if Selectable is present in the tracker map. | ||
| virtual bool selectableIsTracked( | ||
| _In_ swss::Selectable *selectable); | ||
|
|
||
| // Gets the EventHandler for a Selectable. | ||
| virtual SelectableEventHandler *getEventHandlerForSelectable( | ||
| _In_ swss::Selectable *selectable); | ||
|
|
||
| private: | ||
|
|
||
| using SelectableFdToEventHandlerMap = std::unordered_map<int, SelectableEventHandler *>; |
There was a problem hiding this comment.
use shared_ptr instead of pointers
There was a problem hiding this comment.
Doesn't look like w should be using shared_ptr here. Do you use any benefit of using shared_ptr?
There was a problem hiding this comment.
yes, benefit is to not lose trakc of pointers and prevent memory leak, please use shared_ptr, as is used in entire syncd project
|
change to first keyword static requires declaration in cpp file since it's considered a field |
3198dc1 to
38739fb
Compare
link event damper. - Link event damper running on each port will have its own SelectableTimer. This class helps create a mapping of SelectableTimer and object that created the SelectableTimer so that when timer is fired, proper EventHandler object can be invoked. HLD: sonic-net/SONiC#1071
38739fb to
0fe378f
Compare
|
Adding @Junchao-Mellanox for review. |
| } | ||
|
|
||
| int fd = selectable->getFd(); | ||
| if (eventHandler == nullptr) |
There was a problem hiding this comment.
move the check before line 20
There was a problem hiding this comment.
althoug he wanted to log fd number in error message, anyway please add empty line before if()
|
Hi @Ashish1805 and @kcudnik, This PR has been inactive for nearly 2 years. I'm picking up the link event damping feature and plan to open a new PR that supersedes this one, addressing all outstanding review comments:
Will credit @Ashish1805 as original author. See also my comment on #1334 regarding the overall design clarification. |
…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) Co-Authored-By: Ashish Singh <ashish.singh@google.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…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>
HLD: sonic-net/SONiC#1071