srt: [core] High CPU load on Windows
OS Host: Windows 10 64 bits SRT version: latest git (f5f52c02c27d7a8d7050a746eebee6e3d1b33aaa) Program: srt-live-transmit.exe (32 bits compile)
Commandline used:
srt-live-transmit "srt://wowza_server....." udp://127.0.0.1:1234 -s:10
It starts using about 0.2% of CPU load. After some hours (8 or even more), it jumps to about 70% of CPU load. However memory usage keeps stable at 2 MB.
How can I capture the moment when this issue happens ? I have my toolchain ready for anything you want me to compile.
Regards
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 48 (13 by maintainers)
Commits related to this issue
- quick fix for issue 669 (https://github.com/Haivision/srt/issues/669#issuecomment-527062037) — committed to wakabayashik/srt by wakabayashik 4 years ago
- quick fix for issue 669 * https://github.com/Haivision/srt/issues/669#issuecomment-527062037 * https://github.com/Haivision/srt/issues/669#issuecomment-512694490 — committed to wakabayashik/srt by wakabayashik 4 years ago
So just refining my suggested fix further, my local tests suggest that CTimer::getTime() doesn’t need to be epoch-based (this is obviously permissible as can be seen from the Apple code path to the rdtsc call at the top of the function), so I think CTimer::getTime() could just be like this:
This plus the simplification of gettimeofday as per two posts up resolves the high CPU issue caused by the pthread_cond_timedwait issue while preserving the high resolution timer code needed elsewhere in SRT for Windows.
Thank you all for the excellent descriptions. I believe I have isolated this defect and can explain why it is happening. I will share a workaround that may resolve the issue until an official fix is made.
System: Windows 10 Enterprise version 1703 64-bit running on Intel Core I7-6820HQ CPU @ 2.70 GHz SRT version 2e6037e pthread-win32 version 19fd505 Built with Visual Studio 15.9.7 (vc++14.14)
Steps to reproduce the problem:
srt-live-transmit.exe srt://:4000 file://con > null
Isolation and explanation:
Possible Workaround: In SRTCompat_gettimeofday() in win_time.cpp change
if (isFirstCall)
toif (true)
. This causes ftime() to be used every time to get the current time from the system. This workaround may not work well on older systems if the resolution of ftime() is coarser than 10 ms.Fix: Need to change SRTCompat_gettimeofday() so that it doesn’t try to compute absolute time using QueryFrequencyCounter().
@vidanio Why did you close the issue? Still looks like something to investigate.
Also running here since 2 hours ago.
I just started the test with version 1.3.2 that you indicate.