From ca2a0be297732b8cd8b2f6635bc6be6d6a717860 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 7 Oct 2015 18:05:23 +0000 Subject: set statistics --- src/set/Makefile.am | 1 + src/set/gnunet-service-set.c | 8 ++++++++ src/set/gnunet-service-set.h | 3 +++ src/set/gnunet-service-set_union.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/src/set/Makefile.am b/src/set/Makefile.am index 5f7888221..5da0c564a 100644 --- a/src/set/Makefile.am +++ b/src/set/Makefile.am @@ -50,6 +50,7 @@ gnunet_service_set_SOURCES = \ gnunet-service-set_protocol.h gnunet_service_set_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/cadet/libgnunetcadet.la \ $(top_builddir)/src/block/libgnunetblock.la \ diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 0557bc1f2..cc172974e 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c @@ -25,6 +25,7 @@ */ #include "gnunet-service-set.h" #include "gnunet-service-set_protocol.h" +#include "gnunet_statistics_service.h" /** * How long do we hold on to an incoming channel if there is @@ -137,6 +138,11 @@ static uint32_t lazy_copy_cookie = 1; */ static uint32_t suggest_id = 1; +/** + * Statistics handle. + */ +struct GNUNET_STATISTICS_Handle *_GSS_statistics; + /** * Get set that is owned by the given client, if any. @@ -1716,6 +1722,7 @@ shutdown_task (void *cls, GNUNET_CADET_disconnect (cadet); cadet = NULL; } + GNUNET_STATISTICS_destroy (_GSS_statistics, GNUNET_YES); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); } @@ -1987,6 +1994,7 @@ run (void *cls, &handle_client_disconnect, NULL); GNUNET_SERVER_add_handlers (server, server_handlers); + _GSS_statistics = GNUNET_STATISTICS_create ("set", cfg); cadet = GNUNET_CADET_connect (cfg, NULL, &channel_new_cb, &channel_end_cb, diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h index bc3052f02..982967744 100644 --- a/src/set/gnunet-service-set.h +++ b/src/set/gnunet-service-set.h @@ -589,6 +589,9 @@ struct Set }; +extern struct GNUNET_STATISTICS_Handle *_GSS_statistics; + + /** * Destroy the given operation. Call the implementation-specific * cancel function of the operation. Disconnects from the remote diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 2940c3c2d..04fbba348 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c @@ -24,6 +24,7 @@ */ #include "platform.h" #include "gnunet_util_lib.h" +#include "gnunet_statistics_service.h" #include "gnunet-service-set.h" #include "ibf.h" #include "gnunet-service-set_union_strata_estimator.h" @@ -796,10 +797,18 @@ decode_and_send (struct Operation *op) LOG (GNUNET_ERROR_TYPE_DEBUG, "decoding failed, sending larger ibf (size %u)\n", 1<element_hash)); + GNUNET_STATISTICS_update (_GSS_statistics, + "# received elements", + 1, + GNUNET_NO); + if (GNUNET_YES == op_has_element (op, &ee->element_hash)) { /* Got repeated element. Should not happen since * we track demands. */ + GNUNET_STATISTICS_update (_GSS_statistics, + "# repeated elements", + 1, + GNUNET_NO); GNUNET_break (0); GNUNET_free (ee); } @@ -1379,6 +1397,10 @@ union_evaluate (struct Operation *op, op->state->phase = PHASE_EXPECT_SE; LOG (GNUNET_ERROR_TYPE_DEBUG, "Initiating union operation evaluation\n"); + GNUNET_STATISTICS_update (_GSS_statistics, + "# of initiated union operations", + 1, + GNUNET_NO); ev = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, opaque_context); @@ -1415,6 +1437,12 @@ union_accept (struct Operation *op) LOG (GNUNET_ERROR_TYPE_DEBUG, "accepting set union operation\n"); GNUNET_assert (NULL == op->state); + + GNUNET_STATISTICS_update (_GSS_statistics, + "# of accepted union operations", + 1, + GNUNET_NO); + op->state = GNUNET_new (struct OperationState); op->state->se = strata_estimator_dup (op->spec->set->state->se); op->state->demanded_hashes = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO); -- cgit v1.2.3