[Spice-devel] [PATCH spice-server 1/2] red-channel-client: Add message counters to statistics

Frediano Ziglio fziglio at redhat.com
Fri Mar 3 16:45:15 UTC 2017


Show messages sent to clients.
This is useful to understand the message number as an high
message number can affects performance and is not easy to
understand the message count from the byte count (which is
available).

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-channel-client.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 441d20b..80dfdbb 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -148,6 +148,8 @@ struct RedChannelClientPrivate
 
     IncomingMessageBuffer incoming;
     OutgoingMessageBuffer outgoing;
+
+    RedStatCounter out_messages;
 };
 
 static const SpiceDataHeaderOpaque full_header_wrapper;
@@ -373,6 +375,11 @@ static void red_channel_client_constructed(GObject *object)
         self->priv->is_mini_header = FALSE;
     }
     self->priv->incoming.header.data = self->priv->incoming.header_buf;
+
+    RedChannel *channel = self->priv->channel;
+    RedsState* reds = red_channel_get_server(channel);
+    const RedStatNode *node = red_channel_get_stat_node(channel);
+    stat_init_counter(&self->priv->out_messages, reds, node, "out_messages", TRUE);
 }
 
 static void red_channel_client_class_init(RedChannelClientClass *klass)
@@ -1496,6 +1503,8 @@ void red_channel_client_begin_send_message(RedChannelClient *rcc)
         return;
     }
 
+    stat_inc_counter(rcc->priv->out_messages, 1);
+
     /* canceling the latency test timer till the nework is idle */
     red_channel_client_cancel_ping_timer(rcc);
 
-- 
2.9.3



More information about the Spice-devel mailing list