Add some more frame stats granularity, skip frame stats on no-data calls
This commit is contained in:
@@ -42,6 +42,7 @@ namespace network {
|
|||||||
uint32_t jpeg, uint32_t webp, uint32_t analysis,
|
uint32_t jpeg, uint32_t webp, uint32_t analysis,
|
||||||
uint32_t jpegarea, uint32_t webparea,
|
uint32_t jpegarea, uint32_t webparea,
|
||||||
uint16_t njpeg, uint16_t nwebp,
|
uint16_t njpeg, uint16_t nwebp,
|
||||||
|
uint16_t enc, uint16_t scale, uint16_t shot,
|
||||||
uint16_t w, uint16_t h);
|
uint16_t w, uint16_t h);
|
||||||
void mainUpdateClientFrameStats(const char userid[], uint32_t render, uint32_t all,
|
void mainUpdateClientFrameStats(const char userid[], uint32_t render, uint32_t all,
|
||||||
uint32_t ping);
|
uint32_t ping);
|
||||||
@@ -110,6 +111,9 @@ namespace network {
|
|||||||
uint32_t webparea;
|
uint32_t webparea;
|
||||||
uint16_t njpeg;
|
uint16_t njpeg;
|
||||||
uint16_t nwebp;
|
uint16_t nwebp;
|
||||||
|
uint16_t enc;
|
||||||
|
uint16_t scale;
|
||||||
|
uint16_t shot;
|
||||||
uint16_t w;
|
uint16_t w;
|
||||||
uint16_t h;
|
uint16_t h;
|
||||||
uint8_t changedPerc;
|
uint8_t changedPerc;
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ void GetAPIMessager::mainUpdateServerFrameStats(uint8_t changedPerc,
|
|||||||
uint32_t all, uint32_t jpeg, uint32_t webp, uint32_t analysis,
|
uint32_t all, uint32_t jpeg, uint32_t webp, uint32_t analysis,
|
||||||
uint32_t jpegarea, uint32_t webparea,
|
uint32_t jpegarea, uint32_t webparea,
|
||||||
uint16_t njpeg, uint16_t nwebp,
|
uint16_t njpeg, uint16_t nwebp,
|
||||||
|
uint16_t enc, uint16_t scale, uint16_t shot,
|
||||||
uint16_t w, uint16_t h) {
|
uint16_t w, uint16_t h) {
|
||||||
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
if (pthread_mutex_lock(&frameStatMutex))
|
||||||
@@ -137,6 +138,9 @@ void GetAPIMessager::mainUpdateServerFrameStats(uint8_t changedPerc,
|
|||||||
serverFrameStats.webparea = webparea;
|
serverFrameStats.webparea = webparea;
|
||||||
serverFrameStats.njpeg = njpeg;
|
serverFrameStats.njpeg = njpeg;
|
||||||
serverFrameStats.nwebp = nwebp;
|
serverFrameStats.nwebp = nwebp;
|
||||||
|
serverFrameStats.enc = enc;
|
||||||
|
serverFrameStats.scale = scale;
|
||||||
|
serverFrameStats.shot = shot;
|
||||||
serverFrameStats.w = w;
|
serverFrameStats.w = w;
|
||||||
serverFrameStats.h = h;
|
serverFrameStats.h = h;
|
||||||
|
|
||||||
@@ -487,10 +491,15 @@ void GetAPIMessager::netGetFrameStats(char *buf, uint32_t len) {
|
|||||||
|
|
||||||
fprintf(f, "\t\"server_side\" : [\n"
|
fprintf(f, "\t\"server_side\" : [\n"
|
||||||
"\t\t{ \"process_name\": \"Analysis\", \"time\": %u },\n"
|
"\t\t{ \"process_name\": \"Analysis\", \"time\": %u },\n"
|
||||||
|
"\t\t{ \"process_name\": \"Screenshot\", \"time\": %u },\n"
|
||||||
|
"\t\t{ \"process_name\": \"Encoding_total\", \"time\": %u, \"videoscaling\": %u },\n"
|
||||||
"\t\t{ \"process_name\": \"TightJPEGEncoder\", \"time\": %u, \"count\": %u, \"area\": %u },\n"
|
"\t\t{ \"process_name\": \"TightJPEGEncoder\", \"time\": %u, \"count\": %u, \"area\": %u },\n"
|
||||||
"\t\t{ \"process_name\": \"TightWEBPEncoder\", \"time\": %u, \"count\": %u, \"area\": %u }\n"
|
"\t\t{ \"process_name\": \"TightWEBPEncoder\", \"time\": %u, \"count\": %u, \"area\": %u }\n"
|
||||||
"\t],\n",
|
"\t],\n",
|
||||||
serverFrameStats.analysis,
|
serverFrameStats.analysis,
|
||||||
|
serverFrameStats.shot,
|
||||||
|
serverFrameStats.enc,
|
||||||
|
serverFrameStats.scale,
|
||||||
serverFrameStats.jpeg,
|
serverFrameStats.jpeg,
|
||||||
serverFrameStats.njpeg,
|
serverFrameStats.njpeg,
|
||||||
serverFrameStats.jpegarea,
|
serverFrameStats.jpegarea,
|
||||||
|
|||||||
@@ -1085,6 +1085,9 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
|||||||
|
|
||||||
// In case the current resolution is above the max video res, and video was detected,
|
// In case the current resolution is above the max video res, and video was detected,
|
||||||
// scale to that res, keeping aspect ratio
|
// scale to that res, keeping aspect ratio
|
||||||
|
struct timeval scalestart;
|
||||||
|
gettimeofday(&scalestart, NULL);
|
||||||
|
|
||||||
const PixelBuffer *scaledpb = NULL;
|
const PixelBuffer *scaledpb = NULL;
|
||||||
if (videoDetected &&
|
if (videoDetected &&
|
||||||
(maxVideoX < pb->getRect().width() || maxVideoY < pb->getRect().height())) {
|
(maxVideoX < pb->getRect().width() || maxVideoY < pb->getRect().height())) {
|
||||||
@@ -1133,6 +1136,7 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scalingTime = msSince(&scalestart);
|
||||||
|
|
||||||
#pragma omp parallel for schedule(dynamic, 1)
|
#pragma omp parallel for schedule(dynamic, 1)
|
||||||
for (i = 0; i < subrects.size(); ++i) {
|
for (i = 0; i < subrects.size(); ++i) {
|
||||||
|
|||||||
@@ -68,9 +68,16 @@ namespace rfb {
|
|||||||
const RenderedCursor* renderedCursor,
|
const RenderedCursor* renderedCursor,
|
||||||
size_t maxUpdateSize);
|
size_t maxUpdateSize);
|
||||||
|
|
||||||
|
void clearEncodingTime() {
|
||||||
|
encodingTime = 0;
|
||||||
|
};
|
||||||
|
|
||||||
unsigned getEncodingTime() const {
|
unsigned getEncodingTime() const {
|
||||||
return encodingTime;
|
return encodingTime;
|
||||||
};
|
};
|
||||||
|
unsigned getScalingTime() const {
|
||||||
|
return scalingTime;
|
||||||
|
};
|
||||||
|
|
||||||
struct codecstats_t {
|
struct codecstats_t {
|
||||||
uint32_t ms;
|
uint32_t ms;
|
||||||
@@ -192,6 +199,7 @@ namespace rfb {
|
|||||||
bool webpTookTooLong;
|
bool webpTookTooLong;
|
||||||
unsigned encodingTime;
|
unsigned encodingTime;
|
||||||
unsigned maxEncodingTime, framesSinceEncPrint;
|
unsigned maxEncodingTime, framesSinceEncPrint;
|
||||||
|
unsigned scalingTime;
|
||||||
|
|
||||||
EncCache *encCache;
|
EncCache *encCache;
|
||||||
|
|
||||||
|
|||||||
@@ -1194,6 +1194,7 @@ bool VNCSConnectionST::isCongested()
|
|||||||
void VNCSConnectionST::writeFramebufferUpdate()
|
void VNCSConnectionST::writeFramebufferUpdate()
|
||||||
{
|
{
|
||||||
congestion.updatePosition(sock->outStream().length());
|
congestion.updatePosition(sock->outStream().length());
|
||||||
|
encodeManager.clearEncodingTime();
|
||||||
|
|
||||||
// We're in the middle of processing a command that's supposed to be
|
// We're in the middle of processing a command that's supposed to be
|
||||||
// synchronised. Allowing an update to slip out right now might violate
|
// synchronised. Allowing an update to slip out right now might violate
|
||||||
|
|||||||
@@ -186,6 +186,13 @@ namespace rfb {
|
|||||||
return encodeManager.webpstats;
|
return encodeManager.webpstats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned getEncodingTime() const {
|
||||||
|
return encodeManager.getEncodingTime();
|
||||||
|
}
|
||||||
|
unsigned getScalingTime() const {
|
||||||
|
return encodeManager.getScalingTime();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// SConnection callbacks
|
// SConnection callbacks
|
||||||
|
|
||||||
|
|||||||
@@ -1006,14 +1006,20 @@ void VNCServerST::writeUpdate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned shottime = 0;
|
||||||
if (apimessager) {
|
if (apimessager) {
|
||||||
|
struct timeval shotstart;
|
||||||
|
gettimeofday(&shotstart, NULL);
|
||||||
apimessager->mainUpdateScreen(pb);
|
apimessager->mainUpdateScreen(pb);
|
||||||
|
shottime = msSince(&shotstart);
|
||||||
|
|
||||||
trackingFrameStats = 0;
|
trackingFrameStats = 0;
|
||||||
checkAPIMessages(apimessager, trackingFrameStats, trackingClient);
|
checkAPIMessages(apimessager, trackingFrameStats, trackingClient);
|
||||||
}
|
}
|
||||||
|
const rdr::U8 origtrackingFrameStats = trackingFrameStats;
|
||||||
|
|
||||||
EncodeManager::codecstats_t jpegstats, webpstats;
|
EncodeManager::codecstats_t jpegstats, webpstats;
|
||||||
|
unsigned enctime = 0, scaletime = 0;
|
||||||
memset(&jpegstats, 0, sizeof(EncodeManager::codecstats_t));
|
memset(&jpegstats, 0, sizeof(EncodeManager::codecstats_t));
|
||||||
memset(&webpstats, 0, sizeof(EncodeManager::codecstats_t));
|
memset(&webpstats, 0, sizeof(EncodeManager::codecstats_t));
|
||||||
|
|
||||||
@@ -1053,20 +1059,38 @@ void VNCServerST::writeUpdate()
|
|||||||
webpstats.ms += subwebp.ms;
|
webpstats.ms += subwebp.ms;
|
||||||
webpstats.area += subwebp.area;
|
webpstats.area += subwebp.area;
|
||||||
webpstats.rects += subwebp.rects;
|
webpstats.rects += subwebp.rects;
|
||||||
|
|
||||||
|
enctime += (*ci)->getEncodingTime();
|
||||||
|
scaletime += (*ci)->getScalingTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackingFrameStats) {
|
if (trackingFrameStats) {
|
||||||
const unsigned totalMs = msSince(&start);
|
if (enctime) {
|
||||||
|
const unsigned totalMs = msSince(&start);
|
||||||
|
|
||||||
if (apimessager)
|
if (apimessager)
|
||||||
apimessager->mainUpdateServerFrameStats(comparer->changedPerc, totalMs,
|
apimessager->mainUpdateServerFrameStats(comparer->changedPerc, totalMs,
|
||||||
jpegstats.ms, webpstats.ms,
|
jpegstats.ms, webpstats.ms,
|
||||||
analysisMs,
|
analysisMs,
|
||||||
jpegstats.area, webpstats.area,
|
jpegstats.area, webpstats.area,
|
||||||
jpegstats.rects, webpstats.rects,
|
jpegstats.rects, webpstats.rects,
|
||||||
pb->getRect().width(),
|
enctime, scaletime, shottime,
|
||||||
pb->getRect().height());
|
pb->getRect().width(),
|
||||||
|
pb->getRect().height());
|
||||||
|
} else {
|
||||||
|
// Zero encoding time means this was a no-data frame; restore the stats request
|
||||||
|
if (apimessager && pthread_mutex_lock(&apimessager->userMutex) == 0) {
|
||||||
|
|
||||||
|
network::GetAPIMessager::action_data act;
|
||||||
|
act.action = (network::GetAPIMessager::USER_ACTION) origtrackingFrameStats;
|
||||||
|
memcpy(act.data.password, trackingClient, 128);
|
||||||
|
|
||||||
|
apimessager->actionQueue.push_back(act);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&apimessager->userMutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user