[Flex_counter]: Remove poll interval from db key#289
[Flex_counter]: Remove poll interval from db key#289lguohan merged 1 commit intosonic-net:masterfrom
Conversation
|
retest this please |
31fd3f3 to
28ec34a
Compare
syncd/syncd.cpp
Outdated
| std::shared_ptr<swss::NotificationConsumer> restartQuery = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "RESTARTQUERY"); | ||
| std::shared_ptr<swss::ConsumerStateTable> flexCounterState = std::make_shared<swss::ConsumerStateTable>(dbFlexCounter.get(), PFC_WD_STATE_TABLE); | ||
| std::shared_ptr<swss::ConsumerStateTable> flexCounterPlugin = std::make_shared<swss::ConsumerStateTable>(dbFlexCounter.get(), PLUGIN_TABLE); | ||
| std::shared_ptr<swss::ConsumerTable> pfcWdFlexCounter = std::make_shared<swss::ConsumerTable>(dbFlexCounter.get(), FLEX_PFC_WD_TABLE); |
There was a problem hiding this comment.
Flex counter was designed in a way that it's agnostic to its clients. In the case when we'll need to implement, for example, another watchdog, flex counter's code will need to be modified. I don't think that removing polling interval from key with a cost of introducing this dependency is a good thing to do.
28ec34a to
103a7f8
Compare
|
retest this please |
1 similar comment
|
retest this please |
|
@marian-pritsak Could you help to review? Thanks :) |
syncd/syncd_flex_counter.cpp
Outdated
|
|
||
| FlexCounter &fc = getInstance(instanceId); | ||
| fc.m_pollInterval = pollInterval; | ||
| // fc.startFlexCounterThread(); |
There was a problem hiding this comment.
// fc.startFlexCounterThread(); [](start = 1, length = 34)
can we remove this?
| FlexCounter(uint32_t pollInterval); | ||
| static FlexCounter& getInstance(uint32_t pollInterval); | ||
| static void removeInstance(uint32_t pollInterval); | ||
| FlexCounter(std::string instanceId); |
There was a problem hiding this comment.
instanceId [](start = 32, length = 10)
can you explain this instanceId concept? I am not familiar with it.
There was a problem hiding this comment.
It looks like the instanceId is the flex counter group name, so maybe change to groupname is more clear?
In reply to: 166061744 [](ancestors = 166061744)
There was a problem hiding this comment.
Each use case group will be an instance in flex counter and each instance will have a unique instance id which is set as group name for now. The group name is obtained from database.
syncd/syncd_flex_counter.cpp
Outdated
| fc.m_queueCounterIdsMap.erase(counterIter); | ||
| found = true; | ||
| SWSS_LOG_ERROR("Trying to remove nonexisting queue counter Ids 0x%lx", queueVid); | ||
| if (fc.m_queueCounterIdsMap.empty() && fc.m_portCounterIdsMap.empty() && fc.m_queueAttrIdsMap.empty()) |
There was a problem hiding this comment.
fc.m_queueCounterIdsMap.empty() && fc.m_portCounterIdsMap.empty() && fc.m_queueAttrIdsMap.empty( [](start = 12, length = 96)
lots of duplicated code to check empty counter id, suggest to have a function to check it.
There was a problem hiding this comment.
| } | ||
| } | ||
|
|
||
| void FlexCounter::removeQueue( |
There was a problem hiding this comment.
for removeQueue, I think you changed the logic.
In marian's code, he tries to remove the queue id both from m_queueCounterIdsMap and m_queueAttrIdsMap.
In your code, if the first one is not found, you will return and will not remove the queueid from the second map.
Why do you change the logic here? Is this intended? IMO, marian code is more correct.
There was a problem hiding this comment.
Marian's new logic was added recently and current one is the previous version. I didn't rebase it before force push. Will update and be careful next time. Sorry for the inconvenience
syncd/syncd.cpp
Outdated
| } | ||
| else | ||
| { | ||
| SWSS_LOG_ERROR("Object type not supported"); |
There was a problem hiding this comment.
SWSS_LOG_ERROR("Object type not supported"); [](start = 16, length = 44)
should be field not supported, also please print out the actual field for debugging purpose.
syncd/syncd.cpp
Outdated
| swss::KeyOpFieldsValuesTuple kco; | ||
| consumer.pop(kco); | ||
|
|
||
| const auto &key = kfvKey(kco); |
There was a problem hiding this comment.
key [](start = 16, length = 3)
-> groupname
lguohan
left a comment
There was a problem hiding this comment.
overall the refactor looks straightforward, however there is still some surprises, especially the removequeue logic were rewritten which is not exactly the same as before. In the commit message, the author should highlight such change if it is intended, and the author should avoid such change if it is not intended.
3193039 to
602ffbe
Compare
Signed-off-by: Sihui Han <[email protected]>
602ffbe to
4cbd048
Compare
Signed-off-by: Sihui Han <[email protected]>
Signed-off-by: Sihui Han [email protected]