From 79d5251a7a1f15cba527d1f6d6d584499e678a82 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 10 Dec 2015 16:31:20 +0000 Subject: More statistics. --- src/consensus/Makefile.am | 2 ++ src/consensus/gnunet-service-consensus.c | 30 +++++++++++++++++++++++------- src/consensus/test_consensus.conf | 2 +- src/set/gnunet-service-set_union.c | 8 ++++++++ 4 files changed, 34 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/consensus/Makefile.am b/src/consensus/Makefile.am index eb0370eb5..b79e92c60 100644 --- a/src/consensus/Makefile.am +++ b/src/consensus/Makefile.am @@ -46,6 +46,7 @@ gnunet_service_consensus_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/set/libgnunetset.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(GN_LIBINTL) gnunet_service_evil_consensus_SOURCES = \ @@ -55,6 +56,7 @@ gnunet_service_evil_consensus_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/set/libgnunetset.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(GN_LIBINTL) gnunet_service_evil_consensus_CFLAGS = -DEVIL diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index b1c8466cb..fe69b60b6 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c @@ -29,6 +29,7 @@ #include "gnunet_protocols.h" #include "gnunet_applications.h" #include "gnunet_set_service.h" +#include "gnunet_statistics_service.h" #include "gnunet_consensus_service.h" #include "consensus_protocol.h" #include "consensus.h" @@ -485,6 +486,11 @@ static struct GNUNET_SERVER_Handle *srv; */ static struct GNUNET_PeerIdentity my_peer; +/** + * Statistics handle. + */ +struct GNUNET_STATISTICS_Handle *statistics; + static void finish_task (struct TaskEntry *task); @@ -1226,6 +1232,14 @@ commit_set (struct ConsensusSession *session, struct Evilness evil; get_evilness (session, &evil); + if (EVILNESS_NONE != evil.type) + { + /* Useful for evaluation */ + GNUNET_STATISTICS_set (statistics, + "is evil", + 1, + GNUNET_NO); + } switch (evil.type) { case EVILNESS_CRAM_ALL: @@ -1240,7 +1254,8 @@ commit_set (struct ConsensusSession *session, GNUNET_SET_commit (setop->op, set->h); break; } - if ((EVILNESS_CRAM_LEAD == evil.type) && (PHASE_KIND_GRADECAST_LEADER != task->key.kind)) + if ((EVILNESS_CRAM_LEAD == evil.type) && + ((PHASE_KIND_GRADECAST_LEADER != task->key.kind) || SET_KIND_CURRENT != set->key.set_kind)) { GNUNET_SET_commit (setop->op, set->h); break; @@ -1282,6 +1297,10 @@ commit_set (struct ConsensusSession *session, debug_str_task_key (&task->key)); #endif } + GNUNET_STATISTICS_update (statistics, + "# stuffed elements", + evil.num, + GNUNET_NO); GNUNET_SET_commit (setop->op, set->h); break; case EVILNESS_SLACK: @@ -1842,12 +1861,7 @@ task_start_reconcile (struct TaskEntry *task) set_result_cb, task); - if (GNUNET_OK != GNUNET_SET_commit (setop->op, input->h)) - { - GNUNET_break (0); - /* XXX: cleanup? */ - return; - } + commit_set (session, task); } else if (task->key.peer2 == session->local_peer_idx) { @@ -3006,6 +3020,7 @@ shutdown_task (void *cls, while (NULL != sessions_head) destroy_session (sessions_head); + GNUNET_STATISTICS_destroy (statistics, GNUNET_YES); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); } @@ -3058,6 +3073,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GNUNET_SCHEDULER_shutdown (); return; } + statistics = GNUNET_STATISTICS_create ("consensus", cfg); GNUNET_SERVER_add_handlers (server, server_handlers); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL); diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf index 73714e879..38b0d9929 100644 --- a/src/consensus/test_consensus.conf +++ b/src/consensus/test_consensus.conf @@ -5,7 +5,7 @@ GNUNET_TEST_HOME = /tmp/test-consensus/ OPTIONS = -L INFO BINARY = gnunet-service-evil-consensus -EVIL_SPEC = 0;cram-all;noreplace;5 +#EVIL_SPEC = 0;cram-all;noreplace;5 #EVIL_SPEC = 0;cram;5/1;cram;5 #EVIL_SPEC = 0;cram;5/1;cram;3 diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 52e1d0b4c..637ea6e70 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c @@ -1209,6 +1209,10 @@ handle_p2p_elements (void *cls, "# received elements", 1, GNUNET_NO); + GNUNET_STATISTICS_update (_GSS_statistics, + "# exchanged elements", + 1, + GNUNET_NO); if (GNUNET_YES == op_has_element (op, &ee->element_hash)) { @@ -1339,6 +1343,10 @@ handle_p2p_demand (void *cls, (unsigned int) ee->element.size, GNUNET_h2s (&ee->element_hash)); GNUNET_MQ_send (op->mq, ev); + GNUNET_STATISTICS_update (_GSS_statistics, + "# exchanged elements", + 1, + GNUNET_NO); switch (op->spec->result_mode) { -- cgit v1.2.3