[Spice-devel] [PATCH spice 11/11] server/red_worker: add stream stats for debugging
Christophe Fergeau
cfergeau at redhat.com
Tue Apr 10 05:51:34 PDT 2012
Why not, it's properly #ifdef'ed contrary to some unused "might be useful
for debugging" variables...
ACK
Christophe
On Sun, Apr 08, 2012 at 06:43:20PM +0300, Yonit Halperin wrote:
>
> Signed-off-by: Yonit Halperin <yhalperi at redhat.com>
> ---
> server/red_worker.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 50 insertions(+), 0 deletions(-)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 92e1197..ba56e89 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -80,6 +80,7 @@
> #include "main_channel.h"
> #include "spice_timer_queue.h"
>
> +//#define STREAM_STATS
> //#define COMPRESS_STAT
> //#define DUMP_BITMAP
> //#define PIPE_DEBUG
> @@ -442,6 +443,14 @@ typedef struct StreamAgent {
> int frames;
> int drops;
> int fps;
> +#ifdef STREAM_STATS
> + uint64_t num_drops_pipe;
> + uint64_t num_drops_fps;
> + uint64_t total_frames_sent;
> + uint64_t start_mm_time;
> + uint64_t end_mm_time;
> + uint64_t size_sent;
> +#endif
> } StreamAgent;
>
> typedef struct StreamClipItem {
> @@ -2568,6 +2577,22 @@ static void red_stop_stream(RedWorker *worker, Stream *stream)
> spice_assert(!pipe_item_is_linked(&stream_agent->destroy_item));
> stream->refs++;
> red_channel_client_pipe_add(&dcc->common.base, &stream_agent->destroy_item);
> +#ifdef STREAM_STATS
> + if (1) {
> + float passed_mm_time = (stream_agent->end_mm_time - stream_agent->start_mm_time) / 1000.0;
> + spice_debug("stream %ld (%dx%d): frames %lu, drops %lu (pipe %lu, fps %lu), last_fps %d, avg_fps %.2f,"
> + "passed mm %.2f (sec), size %.2f (KB) %.2f (Mbps) %.2f (KBpf)",
> + stream_agent - dcc->stream_agents, stream->width, stream->height,
> + stream_agent->total_frames_sent, stream_agent->num_drops_pipe + stream_agent->num_drops_fps,
> + stream_agent->num_drops_pipe, stream_agent->num_drops_fps,
> + stream_agent->fps,
> + stream_agent->total_frames_sent / passed_mm_time,
> + passed_mm_time,
> + stream_agent->size_sent / 1000.0,
> + ((stream_agent->size_sent * 8.0) / (1000.0 * 1000)) / passed_mm_time,
> + stream_agent->size_sent / 1000.0 / stream_agent->total_frames_sent);
> + }
> +#endif
> }
> worker->streams_size_total -= stream->width * stream->height;
> ring_remove(&stream->link);
> @@ -2823,6 +2848,18 @@ static void red_display_create_stream(DisplayChannelClient *dcc, Stream *stream)
> stream->dest_area.right, stream->dest_area.bottom);
> red_stream_agent_init(dcc, stream);
>
> +#ifdef STREAM_STATS
> + agent->total_frames_sent = 0;
> + agent->num_drops_pipe = 0;
> + agent->num_drops_fps = 0;
> + agent->end_mm_time = 0;
> + if (stream->current) {
> + agent->start_mm_time = stream->current->red_drawable->mm_time;
> + } else {
> + agent->start_mm_time = 0;
> + }
> + agent->size_sent = 0;
> +#endif
> red_channel_client_pipe_add(&dcc->common.base, &agent->create_item);
> }
>
> @@ -3032,6 +3069,11 @@ static inline void pre_stream_item_swap(RedWorker *worker, Stream *stream)
> if (pipe_item_is_linked(&dpi->dpi_pipe_item)) {
> ++agent->drops;
> }
> +#ifdef STREAM_STATS
> + if (pipe_item_is_linked(&dpi->dpi_pipe_item)) {
> + agent->num_drops_pipe++;
> + }
> +#endif
> }
> }
>
> @@ -8424,6 +8466,9 @@ static inline int red_marshall_stream_data(RedChannelClient *rcc,
> uint64_t time_now = red_now();
> size_t outbuf_size;
> if (time_now - agent->last_send_time < (1000 * 1000 * 1000) / agent->fps) {
> +#ifdef STREAM_STATS
> + agent->num_drops_fps++;
> +#endif
> agent->frames--;
> return TRUE;
> }
> @@ -8480,6 +8525,11 @@ static inline int red_marshall_stream_data(RedChannelClient *rcc,
> spice_marshaller_add_ref(base_marshaller,
> dcc->send_data.stream_outbuf, n);
> agent->last_send_time = time_now;
> +#ifdef STREAM_STATS
> + agent->total_frames_sent++;
> + agent->size_sent += n;
> + agent->end_mm_time = drawable->red_drawable->mm_time;
> +#endif
> return TRUE;
> }
>
> --
> 1.7.7.6
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120410/0b0bb0d0/attachment.pgp>
More information about the Spice-devel
mailing list