[Spice-commits] 2 commits - server/red-channel-client.c server/red-channel.c server/red-channel.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Sat Mar 4 01:05:06 UTC 2017


 server/red-channel-client.c |   16 ++++++++++++----
 server/red-channel.c        |    8 --------
 server/red-channel.h        |    1 -
 3 files changed, 12 insertions(+), 13 deletions(-)

New commits:
commit 5c0c9c697593a24d600a95d961d11f7f0c988cfa
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Mar 3 16:42:11 2017 +0000

    red-channel: Move byte statistic to RedChannelClient
    
    As the counters are shared there is no reason why not
    handling the byte count from RedChannelClient directly.
    This remove a dependency and avoid some function calls.
    The only visible difference at user level is that the
    counters are created when a client connects.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 80dfdbb..35bd01a 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -150,6 +150,7 @@ struct RedChannelClientPrivate
     OutgoingMessageBuffer outgoing;
 
     RedStatCounter out_messages;
+    RedStatCounter out_bytes;
 };
 
 static const SpiceDataHeaderOpaque full_header_wrapper;
@@ -380,6 +381,7 @@ static void red_channel_client_constructed(GObject *object)
     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);
+    stat_init_counter(&self->priv->out_bytes, reds, node, "out_bytes", TRUE);
 }
 
 static void red_channel_client_class_init(RedChannelClientClass *klass)
@@ -458,13 +460,10 @@ RedChannel* red_channel_client_get_channel(RedChannelClient *rcc)
 
 static void red_channel_client_data_sent(RedChannelClient *rcc, int n)
 {
-    RedChannel *channel = red_channel_client_get_channel(rcc);
-
     if (rcc->priv->connectivity_monitor.timer) {
         rcc->priv->connectivity_monitor.out_bytes += n;
     }
-    /* TODO: use a signal rather than a hardcoded call to a RedChannel callback? */
-    red_channel_on_output(channel, n);
+    stat_inc_counter(rcc->priv->out_bytes, n);
 }
 
 static void red_channel_client_data_read(RedChannelClient *rcc, int n)
diff --git a/server/red-channel.c b/server/red-channel.c
index d78c628..3808155 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -99,7 +99,6 @@ struct RedChannelPrivate
     pthread_t thread_id;
     RedsState *reds;
     RedStatNode stat;
-    RedStatCounter out_bytes_counter;
 };
 
 enum {
@@ -188,11 +187,6 @@ red_channel_finalize(GObject *object)
     G_OBJECT_CLASS(red_channel_parent_class)->finalize(object);
 }
 
-void red_channel_on_output(RedChannel *self, int n)
-{
-    stat_inc_counter(self->priv->out_bytes_counter, n);
-}
-
 static void
 red_channel_constructed(GObject *object)
 {
@@ -370,8 +364,6 @@ void red_channel_init_stat_node(RedChannel *channel, const RedStatNode *parent,
 
     // TODO check not already initialized
     stat_init_node(&channel->priv->stat, channel->priv->reds, parent, name, TRUE);
-    stat_init_counter(&channel->priv->out_bytes_counter,
-                      channel->priv->reds, &channel->priv->stat, "out_bytes", TRUE);
 }
 
 const RedStatNode *red_channel_get_stat_node(RedChannel *channel)
diff --git a/server/red-channel.h b/server/red-channel.h
index e076e2a..73bd1e1 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -232,7 +232,6 @@ SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel);
 /* channel callback function */
 int red_channel_config_socket(RedChannel *self, RedChannelClient *rcc);
 void red_channel_on_disconnect(RedChannel *self, RedChannelClient *rcc);
-void red_channel_on_output(RedChannel *self, int n);
 void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item);
 void red_channel_reset_thread_id(RedChannel *self);
 const RedStatNode *red_channel_get_stat_node(RedChannel *channel);
commit 256479c53c2bb27b9e37a58087fe834ac2b6db07
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Mar 3 16:44:22 2017 +0000

    red-channel-client: Add message counters to statistics
    
    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>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

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);
 


More information about the Spice-commits mailing list