mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-07 07:28:01 +02:00
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
This commit is contained in:
parent
f69ac31dd9
commit
cf08dce402
7 changed files with 77 additions and 9 deletions
14
bus/stats.c
14
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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue