[common] add PerformanceTimer#893
Conversation
50ac121 to
f9bc905
Compare
78108d0 to
213b741
Compare
|
@qiluo-msft @liuh-80 @lguohan can you help to review and approve it? We need this util PR in for other loading time PRs. |
|
Hi @a114j0y , the performance timer test is unstable, almost every PR need trigger validation 5-10 times to pass this test. can you improve it? Expected equality of these values: |
|
I was looking at the recent PR failures, and it seems like the test is running into issues because it's checking for exact millisecond timings. This is a common issue, things like system load and OS scheduler delays mean that sleep_for is never perfectly exact, so the test can become a bit flaky. It doesn't look like there's any actual bug in your timer logic, it's just the test being a little too strict. I'm working on a small patch to address this. The idea is to have the test check for a range of acceptable values instead of one exact number. This should make it much more stable and prevent false negatives on the CI. I'll have that ready for you to review soon! Let me know what you think @a114j0y cc: @vmittal-msft |
|
Looks like someone beat me to it: #961 Will verify if this solves the issue on my PR |
What I did
Extend the
PerformanceIntervalTimerutility insonic-sairedisrepo to measure API performance.To optimize performance of a periodically invoked function, we not only pay attention to how long it takes to finish execution (busy time), but also care about how long it waits to get executed (idle time). The total time determines the actual throughput in the real world system.
Hence we want to see data in 3 ways:
Idletime between two calls (a gap between this start and the last end, during which the thread just waits)Busytime of each API call (interval between this start and this end, it's the true execution time)Totaltime elapsed (idle + busy)| <- Initial Gap -> | <- - 1st **Execution** - -> | <- 2nd Gap -> | <- - 2nd **Execution** - -> || <---------------- 1st **Total** --------------> | <------------ 2nd **Total**--------------> |Other features
SWSSLOGLEVELusing a file indicator, default level is "INFO", hence we could enable perf logs in a dynamic way.Why I did it
original utility has limited functionality
original utility is in libsairedis, to use it in sonic-swss, there would be much Makefile.am change, not necessary.
a utility tool for swss should be included in swss-common
when enabled on-demand, it could help measure the API performance under scaled traffic