Skip to content

[Flex_counter]: Remove poll interval from db key#289

Merged
lguohan merged 1 commit intosonic-net:masterfrom
sihuihan88:dev/sihan/flex
Feb 7, 2018
Merged

[Flex_counter]: Remove poll interval from db key#289
lguohan merged 1 commit intosonic-net:masterfrom
sihuihan88:dev/sihan/flex

Conversation

@sihuihan88
Copy link
Contributor

Signed-off-by: Sihui Han [email protected]

@sihuihan88
Copy link
Contributor Author

sihuihan88 commented Jan 25, 2018

@sihuihan88
Copy link
Contributor Author

retest this please

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@sihuihan88
Copy link
Contributor Author

retest this please

1 similar comment
@sihuihan88
Copy link
Contributor Author

retest this please

@sihuihan88
Copy link
Contributor Author

sihuihan88 commented Jan 31, 2018

@marian-pritsak Could you help to review? Thanks :)

@lguohan
Copy link
Contributor

lguohan commented Feb 5, 2018

            SWSS_LOG_ERROR("Object type not supported");

minor comments: better to print out the objectType and the field to give more debug information.


Refers to: syncd/syncd.cpp:2682 in 103a7f8. [](commit_id = 103a7f8, deletion_comment = False)


FlexCounter &fc = getInstance(instanceId);
fc.m_pollInterval = pollInterval;
// fc.startFlexCounterThread();
Copy link
Contributor

Choose a reason for hiding this comment

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

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

instanceId [](start = 32, length = 10)

can you explain this instanceId concept? I am not familiar with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

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)

Copy link
Contributor Author

@sihuihan88 sihuihan88 Feb 5, 2018

Choose a reason for hiding this comment

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

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.

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())
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

for example

IsCounterIdsMapEmpty()


In reply to: 166065518 [](ancestors = 166065518)

}
}

void FlexCounter::removeQueue(
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

@sihuihan88 sihuihan88 Feb 5, 2018

Choose a reason for hiding this comment

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

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");
Copy link
Contributor

Choose a reason for hiding this comment

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

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

key [](start = 16, length = 3)

-> groupname

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

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.

@sihuihan88 sihuihan88 force-pushed the dev/sihan/flex branch 4 times, most recently from 3193039 to 602ffbe Compare February 5, 2018 20:15
@lguohan lguohan merged commit dc38653 into sonic-net:master Feb 7, 2018
@sihuihan88 sihuihan88 deleted the dev/sihan/flex branch February 7, 2018 23:28
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
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.

3 participants