Add a debug-level print on the last ~second's maximum encoding time

This commit is contained in:
Lauri Kasanen 2020-09-28 14:37:19 +03:00
parent b30318a68f
commit 99fe70bbd6
2 changed files with 20 additions and 2 deletions

View File

@ -155,7 +155,9 @@ static void updateMaxVideoRes(uint16_t *x, uint16_t *y) {
EncodeManager::EncodeManager(SConnection* conn_, EncCache *encCache_) : conn(conn_),
dynamicQualityMin(-1), dynamicQualityOff(-1),
areaCur(0), videoDetected(false), videoTimer(this), encCache(encCache_)
areaCur(0), videoDetected(false), videoTimer(this),
maxEncodingTime(0), framesSinceEncPrint(0),
encCache(encCache_)
{
StatsVector::iterator iter;
@ -1136,9 +1138,24 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
checkWebpFallback(start);
}
if (start)
if (start) {
encodingTime = msSince(start);
if (vlog.getLevel() >= vlog.LEVEL_DEBUG) {
framesSinceEncPrint++;
if (maxEncodingTime < encodingTime)
maxEncodingTime = encodingTime;
if (framesSinceEncPrint >= rfb::Server::frameRate) {
vlog.info("Max encoding time during the last %u frames: %u ms (limit %u, near limit %.0f)",
framesSinceEncPrint, maxEncodingTime, 1000/rfb::Server::frameRate,
1000/rfb::Server::frameRate * 0.8f);
maxEncodingTime = 0;
framesSinceEncPrint = 0;
}
}
}
if (webpTookTooLong)
activeEncoders[encoderFullColour] = encoderTightJPEG;

View File

@ -182,6 +182,7 @@ namespace rfb {
unsigned webpBenchResult;
bool webpTookTooLong;
unsigned encodingTime;
unsigned maxEncodingTime, framesSinceEncPrint;
EncCache *encCache;