summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-11 17:16:09 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-06-24 16:01:56 +0100
commitcf08dce40281fa128f717b33c64c165cbcd753f6 (patch)
tree8964357c20cc863492158247823737615d2a0ca5
parentf69ac31dd940181a07daa9d00e5e83920b1fa1a0 (diff)
Also record peak values for queued bytes/fds in connection stats
Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34040
-rw-r--r--bus/stats.c14
-rw-r--r--dbus/dbus-connection-internal.h6
-rw-r--r--dbus/dbus-connection.c15
-rw-r--r--dbus/dbus-resources.c34
-rw-r--r--dbus/dbus-resources.h3
-rw-r--r--dbus/dbus-transport.c10
-rw-r--r--dbus/dbus-transport.h4
7 files changed, 77 insertions, 9 deletions
diff --git a/bus/stats.c b/bus/stats.c
index d395bc0e8..28fd49ba3 100644
--- a/bus/stats.c
+++ b/bus/stats.c
@@ -261,8 +261,8 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection,
DBusMessage *reply = NULL;
DBusMessageIter iter, arr_iter;
static dbus_uint32_t stats_serial = 0;
- dbus_uint32_t in_messages, in_bytes, in_fds;
- dbus_uint32_t out_messages, out_bytes, out_fds;
+ dbus_uint32_t in_messages, in_bytes, in_fds, in_peak_bytes, in_peak_fds;
+ dbus_uint32_t out_messages, out_bytes, out_fds, out_peak_bytes, out_peak_fds;
BusRegistry *registry;
BusService *service;
DBusConnection *stats_connection;
@@ -313,14 +313,20 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection,
_dbus_connection_get_stats (stats_connection,
&in_messages, &in_bytes, &in_fds,
- &out_messages, &out_bytes, &out_fds);
+ &in_peak_bytes, &in_peak_fds,
+ &out_messages, &out_bytes, &out_fds,
+ &out_peak_bytes, &out_peak_fds);
if (!asv_add_uint32 (&iter, &arr_iter, "IncomingMessages", in_messages) ||
!asv_add_uint32 (&iter, &arr_iter, "IncomingBytes", in_bytes) ||
!asv_add_uint32 (&iter, &arr_iter, "IncomingFDs", in_fds) ||
+ !asv_add_uint32 (&iter, &arr_iter, "PeakIncomingBytes", in_peak_bytes) ||
+ !asv_add_uint32 (&iter, &arr_iter, "PeakIncomingFDs", in_peak_fds) ||
!asv_add_uint32 (&iter, &arr_iter, "OutgoingMessages", out_messages) ||
!asv_add_uint32 (&iter, &arr_iter, "OutgoingBytes", out_bytes) ||
- !asv_add_uint32 (&iter, &arr_iter, "OutgoingFDs", out_fds))
+ !asv_add_uint32 (&iter, &arr_iter, "OutgoingFDs", out_fds) ||
+ !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingBytes", out_peak_bytes) ||
+ !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingFDs", out_peak_fds))
goto oom;
/* end */
diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h
index 60d514581..3dc5989eb 100644
--- a/dbus/dbus-connection-internal.h
+++ b/dbus/dbus-connection-internal.h
@@ -108,9 +108,13 @@ void _dbus_connection_get_stats (DBusConnection *connection,
dbus_uint32_t *in_messages,
dbus_uint32_t *in_bytes,
dbus_uint32_t *in_fds,
+ dbus_uint32_t *in_peak_bytes,
+ dbus_uint32_t *in_peak_fds,
dbus_uint32_t *out_messages,
dbus_uint32_t *out_bytes,
- dbus_uint32_t *out_fds);
+ dbus_uint32_t *out_fds,
+ dbus_uint32_t *out_peak_bytes,
+ dbus_uint32_t *out_peak_fds);
/* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems
* silly for one function
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 62792dbae..82b05f39b 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -6163,16 +6163,21 @@ _dbus_connection_get_stats (DBusConnection *connection,
dbus_uint32_t *in_messages,
dbus_uint32_t *in_bytes,
dbus_uint32_t *in_fds,
+ dbus_uint32_t *in_peak_bytes,
+ dbus_uint32_t *in_peak_fds,
dbus_uint32_t *out_messages,
dbus_uint32_t *out_bytes,
- dbus_uint32_t *out_fds)
+ dbus_uint32_t *out_fds,
+ dbus_uint32_t *out_peak_bytes,
+ dbus_uint32_t *out_peak_fds)
{
CONNECTION_LOCK (connection);
if (in_messages != NULL)
*in_messages = connection->n_incoming;
- _dbus_transport_get_stats (connection->transport, in_bytes, in_fds);
+ _dbus_transport_get_stats (connection->transport,
+ in_bytes, in_fds, in_peak_bytes, in_peak_fds);
if (out_messages != NULL)
*out_messages = connection->n_outgoing;
@@ -6183,6 +6188,12 @@ _dbus_connection_get_stats (DBusConnection *connection,
if (out_fds != NULL)
*out_fds = _dbus_counter_get_unix_fd_value (connection->outgoing_counter);
+ if (out_peak_bytes != NULL)
+ *out_peak_bytes = _dbus_counter_get_peak_size_value (connection->outgoing_counter);
+
+ if (out_peak_fds != NULL)
+ *out_peak_fds = _dbus_counter_get_peak_unix_fd_value (connection->outgoing_counter);
+
CONNECTION_UNLOCK (connection);
}
#endif /* DBUS_ENABLE_STATS */
diff --git a/dbus/dbus-resources.c b/dbus/dbus-resources.c
index 5f7001cc5..d7346d6f6 100644
--- a/dbus/dbus-resources.c
+++ b/dbus/dbus-resources.c
@@ -58,6 +58,11 @@ struct DBusCounter
long size_value; /**< current size counter value */
long unix_fd_value; /**< current unix fd counter value */
+#ifdef DBUS_ENABLE_STATS
+ long peak_size_value; /**< largest ever size counter value */
+ long peak_unix_fd_value; /**< largest ever unix fd counter value */
+#endif
+
long notify_size_guard_value; /**< call notify function when crossing this size value */
long notify_unix_fd_guard_value; /**< call notify function when crossing this unix fd value */
@@ -91,6 +96,11 @@ _dbus_counter_new (void)
counter->size_value = 0;
counter->unix_fd_value = 0;
+#ifdef DBUS_ENABLE_STATS
+ counter->peak_size_value = 0;
+ counter->peak_unix_fd_value = 0;
+#endif
+
counter->notify_size_guard_value = 0;
counter->notify_unix_fd_guard_value = 0;
counter->notify_function = NULL;
@@ -152,6 +162,11 @@ _dbus_counter_adjust_size (DBusCounter *counter,
counter->size_value += delta;
+#ifdef DBUS_ENABLE_STATS
+ if (counter->peak_size_value < counter->size_value)
+ counter->peak_size_value = counter->size_value;
+#endif
+
#if 0
_dbus_verbose ("Adjusting counter %ld by %ld = %ld\n",
old, delta, counter->size_value);
@@ -182,6 +197,11 @@ _dbus_counter_adjust_unix_fd (DBusCounter *counter,
counter->unix_fd_value += delta;
+#ifdef DBUS_ENABLE_STATS
+ if (counter->peak_unix_fd_value < counter->unix_fd_value)
+ counter->peak_unix_fd_value = counter->unix_fd_value;
+#endif
+
#if 0
_dbus_verbose ("Adjusting counter %ld by %ld = %ld\n",
old, delta, counter->unix_fd_value);
@@ -243,4 +263,18 @@ _dbus_counter_set_notify (DBusCounter *counter,
counter->notify_data = user_data;
}
+#ifdef DBUS_ENABLE_STATS
+long
+_dbus_counter_get_peak_size_value (DBusCounter *counter)
+{
+ return counter->peak_size_value;
+}
+
+long
+_dbus_counter_get_peak_unix_fd_value (DBusCounter *counter)
+{
+ return counter->peak_unix_fd_value;
+}
+#endif
+
/** @} */ /* end of resource limits exported API */
diff --git a/dbus/dbus-resources.h b/dbus/dbus-resources.h
index 4763a97f1..ebbdce97d 100644
--- a/dbus/dbus-resources.h
+++ b/dbus/dbus-resources.h
@@ -51,6 +51,9 @@ void _dbus_counter_set_notify (DBusCounter *counter,
DBusCounterNotifyFunction function,
void *user_data);
+/* if DBUS_ENABLE_STATS */
+long _dbus_counter_get_peak_size_value (DBusCounter *counter);
+long _dbus_counter_get_peak_unix_fd_value (DBusCounter *counter);
DBUS_END_DECLS
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 8ab643bf1..3cbe7998c 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -1486,13 +1486,21 @@ _dbus_transport_set_allow_anonymous (DBusTransport *transport,
void
_dbus_transport_get_stats (DBusTransport *transport,
dbus_uint32_t *queue_bytes,
- dbus_uint32_t *queue_fds)
+ dbus_uint32_t *queue_fds,
+ dbus_uint32_t *peak_queue_bytes,
+ dbus_uint32_t *peak_queue_fds)
{
if (queue_bytes != NULL)
*queue_bytes = _dbus_counter_get_size_value (transport->live_messages);
if (queue_fds != NULL)
*queue_fds = _dbus_counter_get_unix_fd_value (transport->live_messages);
+
+ if (peak_queue_bytes != NULL)
+ *peak_queue_bytes = _dbus_counter_get_peak_size_value (transport->live_messages);
+
+ if (peak_queue_fds != NULL)
+ *peak_queue_fds = _dbus_counter_get_peak_unix_fd_value (transport->live_messages);
}
#endif /* DBUS_ENABLE_STATS */
diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h
index 0aeab183a..4b8215176 100644
--- a/dbus/dbus-transport.h
+++ b/dbus/dbus-transport.h
@@ -100,7 +100,9 @@ void _dbus_transport_set_allow_anonymous (DBusTransport
/* if DBUS_ENABLE_STATS */
void _dbus_transport_get_stats (DBusTransport *transport,
dbus_uint32_t *queue_bytes,
- dbus_uint32_t *queue_fds);
+ dbus_uint32_t *queue_fds,
+ dbus_uint32_t *peak_queue_bytes,
+ dbus_uint32_t *peak_queue_fds);
DBUS_END_DECLS