WiP
[oweals/gnunet.git] / src / dht / gnunet-dht-driver.c
index 9e49bde5c1cb616bd0ac001fd23e3ef3851eeb95..2010326e6fe61eeab0b9dd13eb94220ebabd961f 100644 (file)
@@ -425,6 +425,16 @@ static struct GNUNET_TIME_Absolute connect_start_time;
  */
 static struct GNUNET_TIME_Absolute connect_last_time;
 
+/**
+ * At what time did we start the hostkey creation process.
+ */
+static struct GNUNET_TIME_Absolute hostkey_start_time;
+
+/**
+ * At what time did we start the peer startup process.
+ */
+static struct GNUNET_TIME_Absolute peer_start_time;
+
 /**
  * Boolean value, should the driver issue find peer requests
  * (GNUNET_YES) or should it be left to the service (GNUNET_NO)
@@ -971,7 +981,7 @@ finish_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
     free_meter (get_meter);
 
   GNUNET_asprintf (&temp_get_string,
-                   "DHT Successful GETs (trial %d)", trial_to_run);
+                   "DHT Successful GETs", trial_to_run);
   GNUNET_asprintf (&revision_str, "%llu", revision);
   if (GNUNET_YES == insert_gauger_data)
     GAUGER_ID("DHT_TESTING", temp_get_string, cumulative_successful_gets / (double)cumulative_num_gets, "percent successful", revision_str);
@@ -2032,7 +2042,7 @@ get_stop_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
   struct TestGetContext *test_get = cls;
 
-  if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
+  if ( (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0)
     gets_failed++;
   else
     cumulative_successful_gets++;
@@ -2170,7 +2180,7 @@ put_finished(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
   outstanding_puts--;
   puts_completed++;
 
-  if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
+  if ( (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0)
     fprintf (stderr, "PUT Request failed!\n");
 
   /* Reset the daemon (which peer to insert at) for later put request iterations */
@@ -2944,10 +2954,10 @@ topology_callback(void *cls, const struct GNUNET_PeerIdentity *first,
   unsigned long long total_duration;
   unsigned int new_connections;
   unsigned int new_failed_connections;
-  double conns_per_sec_recent;
-  double conns_per_sec_total;
-  double failed_conns_per_sec_recent;
-  double failed_conns_per_sec_total;
+  long double conns_per_sec_recent;
+  long double conns_per_sec_total;
+  long double failed_conns_per_sec_recent;
+  long double failed_conns_per_sec_total;
   char *temp_conn_string;
   char *temp_conn_failed_string;
   char *revision_str;
@@ -2999,14 +3009,14 @@ topology_callback(void *cls, const struct GNUNET_PeerIdentity *first,
                                                  GNUNET_TIME_absolute_get ()).rel_value
               / 1000;
 
-      failed_conns_per_sec_recent = (double) new_failed_connections / duration;
-      failed_conns_per_sec_total = (double) failed_connections / total_duration;
-      conns_per_sec_recent = (double) new_connections / duration;
-      conns_per_sec_total = (double) total_connections / total_duration;
+      failed_conns_per_sec_recent = (long double) new_failed_connections / duration;
+      failed_conns_per_sec_total = (long double) failed_connections / total_duration;
+      conns_per_sec_recent = (long double) new_connections / duration;
+      conns_per_sec_total = (long double) total_connections / total_duration;
       GNUNET_log (
                   GNUNET_ERROR_TYPE_WARNING,
                   "Recent: %.2f/s, Total: %.2f/s, Recent failed: %.2f/s, total failed %.2f/s\n",
-                  conns_per_sec_recent, CONN_UPDATE_DURATION,
+                  conns_per_sec_recent,
                   conns_per_sec_total, failed_conns_per_sec_recent,
                   failed_conns_per_sec_total);
       connect_last_time = GNUNET_TIME_absolute_get ();
@@ -3085,8 +3095,8 @@ topology_callback(void *cls, const struct GNUNET_PeerIdentity *first,
           = GNUNET_TIME_absolute_get_difference (connect_start_time,
                                                  GNUNET_TIME_absolute_get ()).rel_value
               / 1000;
-      failed_conns_per_sec_total = (double) failed_connections / total_duration;
-      conns_per_sec_total = (double) total_connections / total_duration;
+      failed_conns_per_sec_total = (long double) failed_connections / total_duration;
+      conns_per_sec_total = (long double) total_connections / total_duration;
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Overall connection info --- Total: %u, Total Failed %u/s\n",
                   total_connections, failed_connections);
@@ -3096,26 +3106,26 @@ topology_callback(void *cls, const struct GNUNET_PeerIdentity *first,
                   conns_per_sec_total, failed_conns_per_sec_total);
 
       GNUNET_asprintf (&temp_conn_string,
-                       "DHT Profiler Connection (trial %d)",
+                       "DHT Profiler Connection/s",
                        trial_to_run);
       GNUNET_asprintf (&temp_conn_failed_string,
-                       "DHT Profiler Connection failed (trial %d)",
+                       "DHT Profiler Connection/s failed",
                        trial_to_run);
       GNUNET_asprintf (&revision_str, "%llu", revision);
 
       if (GNUNET_YES == insert_gauger_data)
-        GAUGER_ID("DHT_TESTING", temp_conn_string, conns_per_sec_total, "conns/s", revision_str);
+        GAUGER_ID("DHT_TESTING", temp_conn_string, (float)conns_per_sec_total, "conns/s", revision_str);
       if (GNUNET_YES == insert_gauger_data)
-        GAUGER_ID("DHT_TESTING", temp_conn_failed_string, failed_conns_per_sec_total, "failed_conns", revision_str);
+        GAUGER_ID("DHT_TESTING", temp_conn_failed_string, (float)failed_conns_per_sec_total, "failed_conns", revision_str);
 
       GNUNET_free(temp_conn_string);
       GNUNET_free(temp_conn_failed_string);
       GNUNET_asprintf (&temp_conn_string,
-                       "DHT Profiler Total Connections (trial %d)",
+                       "DHT Profiler Total Connections",
                        trial_to_run);
       GNUNET_asprintf (
                        &temp_conn_failed_string,
-                       "DHT Profiler Total Connections failed (trial %d)",
+                       "DHT Profiler Total Connections failed",
                        trial_to_run);
       if (GNUNET_YES == insert_gauger_data)
         GAUGER_ID("DHT_TESTING", temp_conn_string, total_connections, "conns", revision_str);
@@ -3160,6 +3170,7 @@ peers_started_callback(void *cls, const struct GNUNET_PeerIdentity *id,
     const struct GNUNET_CONFIGURATION_Handle *cfg,
     struct GNUNET_TESTING_Daemon *d, const char *emsg)
 {
+  char *revision_str;
   if (emsg != NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3184,6 +3195,14 @@ peers_started_callback(void *cls, const struct GNUNET_PeerIdentity *id,
 #endif
       GNUNET_SCHEDULER_cancel (die_task);
 
+      GNUNET_asprintf (&revision_str, "%llu", revision);
+      if (GNUNET_YES == insert_gauger_data)
+        GAUGER_ID("DHT_TESTING",
+                  "peer_startup_time",
+                  GNUNET_TIME_absolute_get_duration(peer_start_time).rel_value / (double)num_peers,
+                  "ms/peer", revision_str);
+      GNUNET_free(revision_str);
+
       expected_connections = UINT_MAX;
       if ((pg != NULL) && (peers_left == 0))
         {
@@ -3203,7 +3222,7 @@ peers_started_callback(void *cls, const struct GNUNET_PeerIdentity *id,
                    expected_connections);
         }
 
-      if (expected_connections == GNUNET_SYSERR)
+      if (expected_connections == 0)
         {
           die_task
               = GNUNET_SCHEDULER_add_now (&end_badly,
@@ -3235,6 +3254,7 @@ create_topology()
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Topology set up, have %u expected connections, now starting peers!\n", create_expected_connections);
       GNUNET_TESTING_daemons_continue_startup (pg);
+      peer_start_time = GNUNET_TIME_absolute_get();
     }
   else
     {
@@ -3265,6 +3285,7 @@ static void
 hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id,
     struct GNUNET_TESTING_Daemon *d, const char *emsg)
 {
+  char * revision_str;
   if (emsg != NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -3283,6 +3304,29 @@ hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id,
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "All %d hostkeys created, now creating topology!\n",
                   num_peers);
+
+      GNUNET_asprintf (&revision_str, "%llu", revision);
+      if (GNUNET_YES == insert_gauger_data)
+        {
+          if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (config, "TESTING",
+                                                                   "HOSTKEYSFILE"))
+            {
+              GAUGER_ID("DHT_TESTING",
+                        "HOSTKEY_GENERATION",
+                        GNUNET_TIME_absolute_get_duration(hostkey_start_time).rel_value / (double)num_peers,
+                        "ms/hostkey", revision_str);
+            }
+          else
+            {
+              GAUGER_ID("DHT_TESTING",
+                        "HOSTKEY_GENERATION_REAL",
+                        GNUNET_TIME_absolute_get_duration(hostkey_start_time).rel_value / (double)num_peers,
+                        "ms/hostkey", revision_str);
+            }
+        }
+
+      GNUNET_free(revision_str);
+
       GNUNET_SCHEDULER_cancel (die_task);
       /* Set up task in case topology creation doesn't finish
        * within a reasonable amount of time */
@@ -3803,7 +3847,7 @@ run(void *cls, char * const *args, const char *cfgfile,
                                                          "do_find_peer"))
     do_find_peer = GNUNET_YES;
 
-  if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht",
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing",
                                                            "insert_gauger_data"))
     insert_gauger_data = GNUNET_YES;
 
@@ -4017,6 +4061,7 @@ run(void *cls, char * const *args, const char *cfgfile,
 
   put_meter = create_meter (num_puts, "Puts completed ", GNUNET_YES);
   get_meter = create_meter (num_gets, "Gets completed ", GNUNET_YES);
+  hostkey_start_time = GNUNET_TIME_absolute_get();
   pg
       = GNUNET_TESTING_daemons_start (
                                       cfg,