Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequencer class with lambda response message #2

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

DanielaMurin
Copy link

New Sequencer Class
Sequence number allocated according to the order that the events are received in Syncd
Passed sequence index in Syncd to function logic
The response is turned into a lambda and executed with the correct sequence order
Only added the sequence index to create/remove/set/get/bulk operations

Change-Id: Ic684138907605a2d79db9c85b84c425a5c5b0c59

Change-Id: Ic684138907605a2d79db9c85b84c425a5c5b0c59
DanielaMurin and others added 26 commits August 21, 2024 19:08
Change-Id: I647dc326aac995785ebc1b2d882f85fd2b3d484d
…e second thread pop from the ring buffer and executes the function
Change-Id: I001bdc0f32d81eb847157a2f7ec8bc0faa5de1a8
Change-Id: Ie53906422adfc2027710ef9835dafe141448b84f
Change-Id: I90427922c574e9a5edaa722727878febe6c4d792
Change-Id: I9b7e9de507fb3926aa2c663548e43c97d0b99daa
Change-Id: I380534a136ced86bb0e3e3f06f31be8cc389ec74
Change-Id: I861379abf3db49fbe3488a874f092fbeb136491d
Change-Id: Ia215d224868aef2a5767d7b03082398ffa38e562
Change-Id: I24f0acbea04a99109371705b9529a0461779bfa6
Change-Id: I90ef1f366c6b5f13c856d82f4aa9579c6fa9ff5b
Change-Id: I0e663cd3b7ce155298efd4f74fde86130ccf3b01
Change-Id: Id77121b6a52a535ffda7b31c699e0b6dc9a75ae1
Change-Id: I31bc11dd855c80ae551c1cdd6b750f9c06a24947
Fixed Problems/New Changes:

Should be Tested:
@@ -56,7 +56,8 @@ libSyncd_a_SOURCES = \
WatchdogScope.cpp \
Workaround.cpp \
ZeroMQNotificationProducer.cpp \
syncd_main.cpp
syncd_main.cpp \
Sequencer.cpp

Choose a reason for hiding this comment

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

why is ring buffer not here ?

@@ -0,0 +1,175 @@
#include "Sequencer.h"
#include "swss/logger.h"

Choose a reason for hiding this comment

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

add under ifdef

#include "Sequencer.h"
#include "swss/logger.h"

using namespace syncd;

Choose a reason for hiding this comment

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

why is this needed ?

std::string logMsg;
SequenceStatus status = FAILURE;

logMsg = "multithreaded: Checking for ready responses in queue... \n";

Choose a reason for hiding this comment

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

add under debug flag or under if def

// Check if the next sequence number is in the map
auto seq_data = responses.find(next_seq_to_send);
if (seq_data == responses.end()) {
logMsg += "multithreaded: No next sequence found in queue \n";

Choose a reason for hiding this comment

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

add under debug flag or under if def

if (!ringBuffer || ringBuffer->Started)
{
LogToModuleFile(getNameByRingBuffer(ringBuffer), "popRingBuffer return");
return;

Choose a reason for hiding this comment

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

add counter stats ?


logMsg = "multithreaded: Checking for ready responses in queue... \n";

while (true) {

Choose a reason for hiding this comment

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

condeider adding while not exit thread like in ring buffer

syncd/Syncd.cpp Outdated
@@ -298,39 +383,74 @@ bool Syncd::isInitViewMode() const
return m_asicInitViewMode && m_commandLineOptions->m_enableTempView;
}

void point(_In_ const swss::KeyOpFieldsValuesTuple &kco){

Choose a reason for hiding this comment

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

?still here

syncd/Syncd.cpp Outdated
getApiRingBuffer(kco, ringBuffer);

int sequenceNumber;
if(int seq_status = m_sequencer->allocateSequenceNumber(&sequenceNumber) != Sequencer::SUCCESS)

Choose a reason for hiding this comment

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

no need for if just log return status

syncd/Syncd.cpp Outdated
int sequenceNumber;
if(int seq_status = m_sequencer->allocateSequenceNumber(&sequenceNumber) != Sequencer::SUCCESS)
{
std::string logMsg = "Failed to allocate sequence number: " + std::to_string(seq_status);

Choose a reason for hiding this comment

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

add sww log with warning


// Helper function to execute all ready responses in order
// check how many consecutive responses were executed in sucession and log it
Sequencer::SequenceStatus Sequencer::executeReadyResponses() {

Choose a reason for hiding this comment

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

should not run under lock since block new ecxcute ... ?
but need to think if we lock each iteration - two treads can run in parallel ...

Fixed Problems/New Changes:

Should be Tested:
Copy link

@marvellgit marvellgit left a comment

Choose a reason for hiding this comment

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

need to reduce changes in compare
replace one line with one line ... so compare is better
also all debug crate string shpul dbe done in macro .....

@@ -446,13 +567,14 @@ sai_status_t Syncd::processAttrCapabilityQuery(
capability.create_implemented, capability.set_implemented, capability.get_implemented);
}

m_selectableChannel->set(sai_serialize_status(status), entry, REDIS_ASIC_STATE_COMMAND_ATTR_CAPABILITY_RESPONSE);
sendStausResponseSequence(status, REDIS_ASIC_STATE_COMMAND_ATTR_CAPABILITY_RESPONSE, entry, sequenceNumber);

Choose a reason for hiding this comment

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

diff order than m_selectableChannel->need to verify


attr_list = vidlist.get_attr_list();
attr_count = vidlist.get_attr_count();

Choose a reason for hiding this comment

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

why is this needed - in original code this was defined before ?

Choose a reason for hiding this comment

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

also vidlist was initialized in previous function and not moved as parameter
now reinitilized why ?

@@ -5025,6 +5407,108 @@ static void timerWatchdogCallback(
SWSS_LOG_ERROR("main loop execution exceeded %ld ms", span/1000);
}

void Syncd::getObjectTypeByOperation(

Choose a reason for hiding this comment

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

very complicated :-(

syncd/Syncd.cpp Outdated
@@ -5076,19 +5563,22 @@ void Syncd::run()
SWSS_LOG_NOTICE("starting main loop, ONLY restart query");

if (m_commandLineOptions->m_disableExitSleep)
runMainLoop = false;
runMainLoop = true;

Choose a reason for hiding this comment

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

false became true ?

@@ -5182,11 +5672,59 @@ void Syncd::run()
}
else if (sel == m_flexCounter.get())
{
processFlexCounterEvent(*(swss::ConsumerTable*)sel);
int sequenceNumber;

Choose a reason for hiding this comment

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

really need to have a s ervice or macro - too much code

@@ -5296,3 +5836,73 @@ syncd_restart_type_t Syncd::handleRestartQuery(

return RequestShutdownCommandLineOptions::stringToRestartType(op);
}

void Syncd::sendStatusAndEntryResponse(

Choose a reason for hiding this comment

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

see priviouse note, in should be status mybe alreadt serialized entry and than command type

aviramd and others added 10 commits August 31, 2024 13:17
…ewMode

Fixed Problems/New Changes:

Should be Tested:
Fixed Problems/New Changes:

Should be Tested:
Fixed Problems/New Changes:

Should be Tested:
Change namespace
Add is_exit param
Fix logs
Move statistics to public
Add new statistics parmas

Change-Id: I36f9d45babc7d4ee024aa8afde44edf1615da582
Change-Id: Ib5453d04e8d1f32a6114a32df9149df11c3bb75f
Change-Id: I7aad3550f334ae674eb93dfd66608fefb7aa0add
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.

4 participants