[Spice-commits] 3 commits - server/mjpeg_encoder.c server/mjpeg_encoder.h server/red_channel.c server/red_worker.c
Yonit Halperin
yhalperi at kemper.freedesktop.org
Mon Jun 24 14:43:45 PDT 2013
server/mjpeg_encoder.c | 12 +++++++++++-
server/mjpeg_encoder.h | 7 +++++++
server/red_channel.c | 13 ++-----------
server/red_worker.c | 22 +++++++++++++++-------
4 files changed, 35 insertions(+), 19 deletions(-)
New commits:
commit 648117544f3bc7f9749412be9e22834a98678d31
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Mon Jun 24 14:19:47 2013 -0400
red_worker: improve stream stats readability and ease of parsing
also added start/end-bit-rate and avg-quality to the final stream stats.
diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 92aef27..04b244e 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -221,7 +221,6 @@ MJpegEncoder *mjpeg_encoder_new(int bit_rate_control, uint64_t starting_bit_rate
void mjpeg_encoder_destroy(MJpegEncoder *encoder)
{
- spice_debug("avg-quality %.2f", (double)encoder->avg_quality / encoder->num_frames);
jpeg_destroy_compress(&encoder->cinfo);
free(encoder->row);
free(encoder);
diff --git a/server/red_worker.c b/server/red_worker.c
index f047d29..5b9f387 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -2633,26 +2633,34 @@ static void red_print_stream_stats(DisplayChannelClient *dcc, StreamAgent *agent
#ifdef STREAM_STATS
StreamStats *stats = &agent->stats;
double passed_mm_time = (stats->end - stats->start) / 1000.0;
+ MJpegEncoderStats encoder_stats = {0};
- spice_debug("stream %ld (%dx%d): #frames-in %lu, #in-avg-fps %.2f, #frames-sent %lu, "
- "#drops %lu (pipe %lu, fps %lu), avg_fps %.2f, "
- "ratio(#frames-out/#frames-in) %.2f, "
- "passed-mm-time %.2f (sec), size-total %.2f (MB), size-per-sec %.2f (Mbps), "
- "size-per-frame %.2f (KBpf)",
+ if (agent->mjpeg_encoder) {
+ mjpeg_encoder_get_stats(agent->mjpeg_encoder, &encoder_stats);
+ }
+
+ spice_debug("stream=%ld dim=(%dx%d) #in-frames=%lu #in-avg-fps=%.2f #out-frames=%lu "
+ "out/in=%.2f #drops=%lu (#pipe=%lu #fps=%lu) out-avg-fps=%.2f "
+ "passed-mm-time(sec)=%.2f size-total(MB)=%.2f size-per-sec(Mbps)=%.2f "
+ "size-per-frame(KBpf)=%.2f avg-quality=%.2f "
+ "start-bit-rate(Mbps)=%.2f end-bit-rate(Mbps)=%.2f",
agent - dcc->stream_agents, agent->stream->width, agent->stream->height,
stats->num_input_frames,
stats->num_input_frames / passed_mm_time,
stats->num_frames_sent,
+ (stats->num_frames_sent + 0.0) / stats->num_input_frames,
stats->num_drops_pipe +
stats->num_drops_fps,
stats->num_drops_pipe,
stats->num_drops_fps,
stats->num_frames_sent / passed_mm_time,
- (stats->num_frames_sent + 0.0) / stats->num_input_frames,
passed_mm_time,
stats->size_sent / 1024.0 / 1024.0,
((stats->size_sent * 8.0) / (1024.0 * 1024)) / passed_mm_time,
- stats->size_sent / 1000.0 / stats->num_frames_sent);
+ stats->size_sent / 1000.0 / stats->num_frames_sent,
+ encoder_stats.avg_quality,
+ encoder_stats.starting_bit_rate / (1024.0 * 1024),
+ encoder_stats.cur_bit_rate / (1024.0 * 1024));
#endif
}
commit a9f1a4b75dbba65eb16ce7c5119ec2fbe4563ede
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Mon Jun 24 12:36:31 2013 -0400
mjpeg_encoder: add mjpeg_encoder_get_stats
diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 4460322..92aef27 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -169,6 +169,7 @@ struct MJpegEncoder {
void *cbs_opaque;
/* stats */
+ uint64_t starting_bit_rate;
uint64_t avg_quality;
uint32_t num_frames;
};
@@ -195,6 +196,8 @@ MJpegEncoder *mjpeg_encoder_new(int bit_rate_control, uint64_t starting_bit_rate
enc->first_frame = TRUE;
enc->rate_control_is_active = bit_rate_control;
enc->rate_control.byte_rate = starting_bit_rate / 8;
+ enc->starting_bit_rate = starting_bit_rate;
+
if (bit_rate_control) {
struct timespec time;
@@ -1259,3 +1262,11 @@ uint64_t mjpeg_encoder_get_bit_rate(MJpegEncoder *encoder)
{
return encoder->rate_control.byte_rate * 8;
}
+
+void mjpeg_encoder_get_stats(MJpegEncoder *encoder, MJpegEncoderStats *stats)
+{
+ spice_assert(encoder != NULL && stats != NULL);
+ stats->starting_bit_rate = encoder->starting_bit_rate;
+ stats->cur_bit_rate = mjpeg_encoder_get_bit_rate(encoder);
+ stats->avg_quality = (double)encoder->avg_quality / encoder->num_frames;
+}
diff --git a/server/mjpeg_encoder.h b/server/mjpeg_encoder.h
index 310d289..741ea1c 100644
--- a/server/mjpeg_encoder.h
+++ b/server/mjpeg_encoder.h
@@ -43,6 +43,12 @@ typedef struct MJpegEncoderRateControlCbs {
void (*update_client_playback_delay)(void *opaque, uint32_t delay_ms);
} MJpegEncoderRateControlCbs;
+typedef struct MJpegEncoderStats {
+ uint64_t starting_bit_rate;
+ uint64_t cur_bit_rate;
+ double avg_quality;
+} MJpegEncoderStats;
+
MJpegEncoder *mjpeg_encoder_new(int bit_rate_control, uint64_t starting_bit_rate,
MJpegEncoderRateControlCbs *cbs, void *opaque);
void mjpeg_encoder_destroy(MJpegEncoder *encoder);
@@ -103,5 +109,6 @@ void mjpeg_encoder_client_stream_report(MJpegEncoder *encoder,
void mjpeg_encoder_notify_server_frame_drop(MJpegEncoder *encoder);
uint64_t mjpeg_encoder_get_bit_rate(MJpegEncoder *encoder);
+void mjpeg_encoder_get_stats(MJpegEncoder *encoder, MJpegEncoderStats *stats);
#endif
commit 1377732805dbaadc98d7b1bbe0656908f72113ce
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Mon Jun 24 12:18:31 2013 -0400
spice: silencing most of the ping/pong logging
Those messages are too frequent and don't contribute much
diff --git a/server/red_channel.c b/server/red_channel.c
index 5662041..c0b1781 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -518,7 +518,6 @@ static void red_channel_client_send_ping(RedChannelClient *rcc)
} else {
rcc->latency_monitor.tcp_nodelay = delay_val;
if (!delay_val) {
- spice_debug("switching to TCP_NODELAY");
delay_val = 1;
if (setsockopt(rcc->stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
sizeof(delay_val)) == -1) {
@@ -535,7 +534,6 @@ static void red_channel_client_send_ping(RedChannelClient *rcc)
clock_gettime(CLOCK_MONOTONIC, &ts);
ping.timestamp = ts.tv_sec * 1000000000LL + ts.tv_nsec;
spice_marshall_msg_ping(rcc->send_data.marshaller, &ping);
- spice_debug("time %lu", ping.timestamp);
red_channel_client_begin_send_message(rcc);
}
@@ -709,7 +707,6 @@ static int red_channel_client_pre_create_validate(RedChannel *channel, RedClient
static void red_channel_client_push_ping(RedChannelClient *rcc)
{
- spice_debug(NULL);
spice_assert(rcc->latency_monitor.state == PING_STATE_NONE);
rcc->latency_monitor.state = PING_STATE_WARMUP;
rcc->latency_monitor.warmup_was_sent = FALSE;
@@ -730,7 +727,7 @@ static void red_channel_client_ping_timer(void *opaque)
spice_printerr("ioctl(TIOCOUTQ) failed, %s", strerror(errno));
}
if (so_unsent_size > 0) {
- spice_debug("tcp snd buffer is still occupied. rescheduling ping");
+ /* tcp snd buffer is still occupied. rescheduling ping */
red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
} else {
red_channel_client_push_ping(rcc);
@@ -1352,10 +1349,8 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
clock_gettime(CLOCK_MONOTONIC, &ts);
now = ts.tv_sec * 1000000000LL + ts.tv_nsec;
- spice_debug("now %lu", now);
if (rcc->latency_monitor.state == PING_STATE_WARMUP) {
rcc->latency_monitor.state = PING_STATE_LATENCY;
- spice_debug("warmup roundtrip %.2f (ms)", (now - ping->timestamp)/1000.0/1000.0);
return;
} else if (rcc->latency_monitor.state != PING_STATE_LATENCY) {
spice_warning("unexpected");
@@ -1366,7 +1361,6 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
if (!rcc->latency_monitor.tcp_nodelay) {
int delay_val = 0;
- spice_debug("switching to back TCP_NODELAY=0");
if (setsockopt(rcc->stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
sizeof(delay_val)) == -1) {
if (errno != ENOTSUP) {
@@ -1384,10 +1378,7 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
if (rcc->latency_monitor.roundtrip < 0 ||
now - ping->timestamp < rcc->latency_monitor.roundtrip) {
rcc->latency_monitor.roundtrip = now - ping->timestamp;
- spice_debug("roundtrip ms %.2f (ms)", rcc->latency_monitor.roundtrip/1000.0/1000.0);
- } else {
- spice_debug("not updating roundtrip. The latest latency measured was bigger (%.2f)",
- (now - ping->timestamp)/1000.0/1000.0);
+ spice_debug("update roundtrip %.2f(ms)", rcc->latency_monitor.roundtrip/1000.0/1000.0);
}
rcc->latency_monitor.last_pong_time = now;
More information about the Spice-commits
mailing list