forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for saiplayer bulk API and add performance timers (sonic-…
…net#666) * [sairedis] Add PerformanceIntervalTimer class * [sairedis] Add deserialize tests * [sairedis] Add performance timer to route_entry bulk create * [sairedis] Add PerformanceIntervalTimer class to makefile * [saiplayer] Add support for bulk generic API and bulk route_entry * [vs] Add performance timer for route_entry create API * [syncd] Fix for ZeroMQSelectableChannel thread join * [syncd] Add performance timers to syncd route_entry create and db
- Loading branch information
Showing
11 changed files
with
627 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include "swss/sal.h" | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
namespace sairediscommon | ||
{ | ||
class PerformanceIntervalTimer | ||
{ | ||
public: | ||
|
||
static constexpr unsigned int DEFAULT_LIMIT = 10000; | ||
|
||
public: | ||
|
||
PerformanceIntervalTimer( | ||
_In_ const char* msg, | ||
_In_ uint64_t limit = DEFAULT_LIMIT); | ||
|
||
~PerformanceIntervalTimer() = default; // non virtual | ||
|
||
public: | ||
|
||
void start(); | ||
|
||
void stop(); | ||
|
||
void inc( | ||
_In_ uint64_t val = 1); | ||
|
||
void reset(); | ||
|
||
public: | ||
|
||
static bool m_enable; | ||
|
||
private: | ||
|
||
std::string m_msg; | ||
|
||
std::chrono::time_point<std::chrono::high_resolution_clock> m_start; | ||
std::chrono::time_point<std::chrono::high_resolution_clock> m_stop; | ||
|
||
uint64_t m_limit; | ||
uint64_t m_count; | ||
uint64_t m_calls; | ||
uint64_t m_total; | ||
}; | ||
} |
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,63 @@ | ||
#include "PerformanceIntervalTimer.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
using namespace sairediscommon; | ||
|
||
bool PerformanceIntervalTimer::m_enable = true; | ||
|
||
PerformanceIntervalTimer::PerformanceIntervalTimer( | ||
_In_ const char*msg, | ||
_In_ uint64_t limit): | ||
m_msg(msg), | ||
m_limit(limit) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
reset(); | ||
} | ||
|
||
void PerformanceIntervalTimer::start() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_start = std::chrono::high_resolution_clock::now(); | ||
} | ||
|
||
void PerformanceIntervalTimer::stop() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_stop = std::chrono::high_resolution_clock::now(); | ||
} | ||
|
||
void PerformanceIntervalTimer::inc( | ||
_In_ uint64_t val) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_count += val; | ||
|
||
m_calls++; | ||
|
||
m_total += std::chrono::duration_cast<std::chrono::nanoseconds>(m_stop-m_start).count(); | ||
|
||
if (m_count >= m_limit) | ||
{ | ||
if (m_enable) | ||
{ | ||
SWSS_LOG_NOTICE("%zu (calls %zu) %s op took: %zu ms", m_count, m_calls, m_msg.c_str(), m_total/1000000); | ||
} | ||
|
||
reset(); | ||
} | ||
} | ||
|
||
void PerformanceIntervalTimer::reset() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_count = 0; | ||
m_calls = 0; | ||
m_total = 0; | ||
} |
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.