-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Break Before Make mechanism to syncd comparison logic (#642)
* [player] Add more log info when fail response * [syncd] Send notify view response even when exception happen * [vs] Add resource limiter * [vs] Start using resource limiter * [syncd] Fix vendor sai functions names check * [syncd] Add apply view remove object sanity checks * [syncd] Lower NPU switch log to notice * [syncd] Add simlar best match candidate with most same attributes * [syncd] Add BreakConfig class * [syncd] Add break config option to command line * [syncd] Add comparison logic break before make path * [syncd] Add break config parser * [syncd] Add break config size method * [syncd] Fix command line parser help message * [syncd] Start using break config parser * Update aspell * [tests] Add unittests
- Loading branch information
Showing
38 changed files
with
1,046 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "BreakConfig.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
using namespace syncd; | ||
|
||
void BreakConfig::insert( | ||
_In_ sai_object_type_t objectType) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_set.insert(objectType); | ||
} | ||
|
||
void BreakConfig::remove( | ||
_In_ sai_object_type_t objectType) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
auto it = m_set.find(objectType); | ||
|
||
if (it != m_set.end()) | ||
{ | ||
m_set.erase(it); | ||
} | ||
} | ||
|
||
void BreakConfig::clear() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_set.clear(); | ||
} | ||
|
||
bool BreakConfig::shouldBreakBeforeMake( | ||
_In_ sai_object_type_t objectType) const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
return m_set.find(objectType) != m_set.end(); | ||
} | ||
|
||
size_t BreakConfig::size() const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
return m_set.size(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
extern "C"{ | ||
#include "sai.h" | ||
} | ||
|
||
#include <set> | ||
|
||
namespace syncd | ||
{ | ||
class BreakConfig | ||
{ | ||
public: | ||
|
||
BreakConfig() = default; | ||
|
||
~BreakConfig() = default; | ||
|
||
public: | ||
|
||
void insert( | ||
_In_ sai_object_type_t objectType); | ||
|
||
void remove( | ||
_In_ sai_object_type_t objectType); | ||
|
||
void clear(); | ||
|
||
bool shouldBreakBeforeMake( | ||
_In_ sai_object_type_t objectType) const; | ||
|
||
size_t size() const; | ||
|
||
private: | ||
|
||
std::set<sai_object_type_t> m_set; | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "BreakConfigParser.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
#include "meta/sai_serialize.h" | ||
|
||
using namespace syncd; | ||
|
||
std::shared_ptr<BreakConfig> BreakConfigParser::parseBreakConfig( | ||
_In_ const std::string& filePath) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
auto config = std::make_shared<BreakConfig>(); | ||
|
||
if (filePath.size() == 0) | ||
{ | ||
return config; // return empty config | ||
} | ||
|
||
std::ifstream file(filePath); | ||
|
||
if (!file.is_open()) | ||
{ | ||
SWSS_LOG_ERROR("failed to open break config file: %s: errno: %s, returning empty config", filePath.c_str(), strerror(errno)); | ||
|
||
return config; | ||
} | ||
|
||
std::string line; | ||
|
||
while (getline(file, line)) | ||
{ | ||
if (line.size() > 0 && (line[0] == '#' || line[0] == ';')) | ||
{ | ||
continue; | ||
} | ||
|
||
sai_object_type_t objectType; | ||
|
||
try | ||
{ | ||
sai_deserialize_object_type(line, objectType); | ||
|
||
config->insert(objectType); | ||
|
||
SWSS_LOG_INFO("inserting %s to break config", line.c_str()); | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
SWSS_LOG_WARN("failed to parse '%s' as sai_object_type_t", line.c_str()); | ||
} | ||
} | ||
|
||
SWSS_LOG_NOTICE("break config parse success, contains %zu entries", config->size()); | ||
|
||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include "BreakConfig.h" | ||
|
||
#include <memory> | ||
|
||
namespace syncd | ||
{ | ||
class BreakConfigParser | ||
{ | ||
private: | ||
|
||
BreakConfigParser() = delete; | ||
|
||
~BreakConfigParser() = delete; | ||
|
||
public: | ||
|
||
static std::shared_ptr<BreakConfig> parseBreakConfig( | ||
_In_ const std::string& filePath); | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.