[Spice-devel] [PATCH spice-server 2/3] spicevmc: Add some statistics
Jonathon Jongsma
jjongsma at redhat.com
Tue Feb 14 21:12:54 UTC 2017
On Tue, 2017-02-14 at 15:51 +0000, Frediano Ziglio wrote:
> Allows to see compressed/uncompressed ratio
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/spicevmc.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> Ping.
>
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 9bcbada..174a04a 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -114,6 +114,8 @@ struct RedVmcChannel
> RedVmcPipeItem *pipe_item;
> RedCharDeviceWriteBuffer *recv_from_client_buf;
> uint8_t port_opened;
> + RedStatCounter in_data, in_compressed, in_decompressed;
> + RedStatCounter out_data, out_compressed, out_uncompressed;
I see we don't have anything about this in our coding style guidelines,
but I generally don't like having multiple variables declared on a
single line.
Otherwise seems fine
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
> };
>
> struct RedVmcChannelClass
> @@ -194,6 +196,15 @@ red_vmc_channel_constructed(GObject *object)
> client_cbs.connect = spicevmc_connect;
> red_channel_register_client_cbs(RED_CHANNEL(self), &client_cbs,
> NULL);
>
> + red_channel_init_stat_node(RED_CHANNEL(self), NULL, "spicevmc");
> + const RedStatNode *stat =
> red_channel_get_stat_node(RED_CHANNEL(self));
> + stat_init_counter(&self->in_data, reds, stat, "in_data", TRUE);
> + stat_init_counter(&self->in_compressed, reds, stat,
> "in_compressed", TRUE);
> + stat_init_counter(&self->in_decompressed, reds, stat,
> "in_decompressed", TRUE);
> + stat_init_counter(&self->out_data, reds, stat, "out_data",
> TRUE);
> + stat_init_counter(&self->out_compressed, reds, stat,
> "out_compressed", TRUE);
> + stat_init_counter(&self->out_uncompressed, reds, stat,
> "out_uncompressed", TRUE);
> +
> #ifdef USE_LZ4
> red_channel_set_cap(RED_CHANNEL(self),
> SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4);
> #endif
> @@ -305,6 +316,8 @@ static RedVmcPipeItem*
> try_compress_lz4(RedVmcChannel *channel, int n, RedVmcPip
> BUF_SIZE);
>
> if (compressed_data_count > 0 && compressed_data_count < n) {
> + stat_inc_counter(channel->out_uncompressed, n);
> + stat_inc_counter(channel->out_compressed,
> compressed_data_count);
> msg_item_compressed->type = SPICE_DATA_COMPRESSION_TYPE_LZ4;
> msg_item_compressed->uncompressed_data_size = n;
> msg_item_compressed->buf_used = compressed_data_count;
> @@ -355,6 +368,7 @@ static RedPipeItem
> *spicevmc_chardev_read_msg_from_dev(RedCharDevice *self,
> return &msg_item_compressed->base;
> }
> #endif
> + stat_inc_counter(channel->out_data, n);
> msg_item->uncompressed_data_size = n;
> msg_item->buf_used = n;
> return &msg_item->base;
> @@ -532,6 +546,8 @@ static int handle_compressed_msg(RedVmcChannel
> *channel, RedChannelClient *rcc,
> (char
> *)decompressed,
> compressed_data_msg
> ->compressed_size,
> compressed_data_msg
> ->uncompressed_size);
> + stat_inc_counter(channel->in_compressed,
> compressed_data_msg->compressed_size);
> + stat_inc_counter(channel->in_decompressed,
> decompressed_size);
> break;
> }
> #endif
> @@ -566,6 +582,7 @@ static int
> spicevmc_red_channel_client_handle_message_parsed(RedChannelClient *r
> switch (type) {
> case SPICE_MSGC_SPICEVMC_DATA:
> spice_assert(channel->recv_from_client_buf->buf == msg);
> + stat_inc_counter(channel->in_data, size);
> channel->recv_from_client_buf->buf_used = size;
> red_char_device_write_buffer_add(channel->chardev, channel-
> >recv_from_client_buf);
> channel->recv_from_client_buf = NULL;
More information about the Spice-devel
mailing list