From 93002ad128d9dc23f80fc2384e0dd3f033315c14 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 30 May 2011 15:33:19 +0000 Subject: [PATCH] track performance data --- src/fs/gnunet-service-fs_cp.c | 6 ++++- src/fs/gnunet-service-fs_pe.c | 46 +++++++++++++++++++++++++++++++---- src/fs/gnunet-service-fs_pr.c | 18 +++++++++++++- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index e0154f2d7..7123db73a 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -1177,6 +1177,10 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, return NULL; } /* existing request has lower TTL, drop old one! */ + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# P2P searches active"), + -1, + GNUNET_NO); priority += prd->priority; GSF_pending_request_cancel_ (pr); GNUNET_assert (GNUNET_YES == @@ -1217,7 +1221,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, peerreq, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# P2P searches received"), + gettext_noop ("# P2P query messages received and processed"), 1, GNUNET_NO); GNUNET_STATISTICS_update (GSF_stats, diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 2ae50259d..6c4d3df17 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -119,6 +119,16 @@ struct PeerPlan */ static struct GNUNET_CONTAINER_MultiHashMap *plans; +/** + * Sum of all transmission counters (equals total delay for all plan entries). + */ +static unsigned long long total_delay; + +/** + * Number of plan entries. + */ +static unsigned long long plan_count; + /** * Figure out when and how to transmit to the given peer. @@ -142,15 +152,19 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) { struct GSF_PendingRequestData *prd; + struct GNUNET_TIME_Relative delay; + GNUNET_STATISTICS_set (GSF_stats, + gettext_noop ("# average retransmission delay (ms)"), + total_delay * 1000LL / plan_count, + GNUNET_NO); prd = GSF_pending_request_get_data_ (rp->pr); // FIXME: calculate 'rp->earliest_transmission'! - // FIXME: claculate 'rp->priority'! + // FIXME: claculate 'rp->priority'! + delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + rp->transmission_counter); rp->earliest_transmission - = GNUNET_TIME_relative_to_absolute - (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - rp->transmission_counter)); + = GNUNET_TIME_relative_to_absolute (delay); #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Earliest (re)transmission for `%s' in %us\n", @@ -215,6 +229,7 @@ transmit_message_callback (void *cls, rp->hn = NULL; rp->last_transmission = GNUNET_TIME_absolute_get (); rp->transmission_counter++; + total_delay++; #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing plan %p executed %u times, planning retransmission\n", @@ -222,6 +237,10 @@ transmit_message_callback (void *cls, rp->transmission_counter); #endif plan (pp, rp); + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# queries messages sent to other peers"), + 1, + GNUNET_NO); return msize; } @@ -330,6 +349,11 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } prd = GSF_pending_request_get_data_ (pr); + plan_count++; + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# query plan entries"), + 1, + GNUNET_NO); rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan)); #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -381,6 +405,7 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) GNUNET_CONTAINER_DLL_remove (prd->rp_head, prd->rp_tail, rp); + plan_count--; GNUNET_free (rp); } GNUNET_CONTAINER_heap_destroy (pp->priority_heap); @@ -390,8 +415,14 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) GNUNET_CONTAINER_DLL_remove (prd->rp_head, prd->rp_tail, rp); + plan_count--; GNUNET_free (rp); } + GNUNET_STATISTICS_set (GSF_stats, + gettext_noop ("# query plan entries"), + plan_count, + GNUNET_NO); + GNUNET_CONTAINER_heap_destroy (pp->delay_heap); GNUNET_free (pp); } @@ -416,8 +447,13 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr) GNUNET_CONTAINER_DLL_remove (prd->rp_head, prd->rp_tail, rp); + plan_count--; GNUNET_free (rp); } + GNUNET_STATISTICS_set (GSF_stats, + gettext_noop ("# query plan entries"), + plan_count, + GNUNET_NO); } diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 1347f7789..d4f14985b 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -1146,6 +1146,12 @@ process_local_reply (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No further local responses available.\n"); #endif + if ( (pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK) || + (pr->public_data.type == GNUNET_BLOCK_TYPE_FS_IBLOCK) ) + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# requested DBLOCK or IBLOCK not found"), + 1, + GNUNET_NO); goto check_error_and_continue; } #if DEBUG_FS @@ -1174,7 +1180,17 @@ process_local_reply (void *cls, anonymity, expiration, uid, &process_local_reply, pr)) - return; /* we're done */ + { + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# on-demand lookups performed successfully"), + 1, + GNUNET_NO); + return; /* we're done */ + } + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# on-demand lookups failed"), + 1, + GNUNET_NO); GNUNET_SCHEDULER_cancel (pr->warn_task); pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task, -- 2.25.1