From bb71cd4ec43ade598907be37fbd4a42dc064ba80 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Thu, 1 Oct 2020 13:00:34 +0300 Subject: [PATCH] Have stats react faster to big cpu lag spikes --- common/rfb/VNCSConnectionST.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index fc4581d..6391d9e 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -1259,6 +1259,17 @@ void VNCSConnectionST::writeDataUpdate() if (ms >= limit) { bstats[BS_CPU_SLOW].push_back(lastRealUpdate); bstats_total[BS_CPU_SLOW]++; + + // If it was several frames' worth, add several so as to react faster + int i = ms / limit; + i--; + for (; i > 0; i--) { + bstats[BS_CPU_SLOW].push_back(lastRealUpdate); + bstats_total[BS_CPU_SLOW]++; + + bstats[BS_FRAME].push_back(lastRealUpdate); + bstats_total[BS_FRAME]++; + } } else if (ms >= limit * 0.8f) { bstats[BS_CPU_CLOSE].push_back(lastRealUpdate); bstats_total[BS_CPU_CLOSE]++;