gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30475 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r30475 - gnunet/src/ats
Date: Wed, 30 Oct 2013 13:20:10 +0100

Author: wachs
Date: 2013-10-30 13:20:10 +0100 (Wed, 30 Oct 2013)
New Revision: 30475

Modified:
   gnunet/src/ats/libgnunet_plugin_ats_proportional.c
   gnunet/src/ats/perf_ats_solver.c
Log:
basic benchmark functionality working


Modified: gnunet/src/ats/libgnunet_plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/libgnunet_plugin_ats_proportional.c  2013-10-30 12:19:29 UTC 
(rev 30474)
+++ gnunet/src/ats/libgnunet_plugin_ats_proportional.c  2013-10-30 12:20:10 UTC 
(rev 30475)
@@ -1083,8 +1083,7 @@
    * - update quota for previous address network
    * - update quota for this address network
    */
-  prev = get_active_address (s,
-                            s->addresses, peer);
+  prev = get_active_address (s, s->addresses, peer);
   if (NULL != prev)
   {
     net_prev = (struct Network *) prev->solver_information;

Modified: gnunet/src/ats/perf_ats_solver.c
===================================================================
--- gnunet/src/ats/perf_ats_solver.c    2013-10-30 12:19:29 UTC (rev 30474)
+++ gnunet/src/ats/perf_ats_solver.c    2013-10-30 12:20:10 UTC (rev 30475)
@@ -32,9 +32,9 @@
 #include "gnunet_ats_plugin.h"
 #include "test_ats_api_common.h"
 
-#define DEFAULT_PEERS_START     1
-#define DEFAULT_PEERS_END       1
-#define DEFAULT_ADDRESSES       1
+#define DEFAULT_PEERS_START     10
+#define DEFAULT_PEERS_END       10
+#define DEFAULT_ADDRESSES       10
 #define DEFAULT_ATS_COUNT       2
 
 /**
@@ -64,6 +64,8 @@
   int opt_update_percent;
   int opt_update_quantity;
 
+  int bulk_running;
+
   char *ats_string;
 
   /**
@@ -163,7 +165,7 @@
 
 
 static void
-update_single_addresses (struct ATS_Address *cur)
+perf_update_address (struct ATS_Address *cur)
 {
   int r_type;
   int r_val;
@@ -201,6 +203,18 @@
 static void
 bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 {
+  if (0 == ntohl(address->assigned_bw_out.value__) &&
+      0 == ntohl(address->assigned_bw_in.value__))
+    return;
+
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+      "Bandwidth changed addresses %s %p to %llu Bps out / %llu Bps in\n",
+      GNUNET_i2s (&address->peer),
+      address,
+      ntohl(address->assigned_bw_out.value__),
+      ntohl(address->assigned_bw_in.value__));
+  if (GNUNET_YES == ph.bulk_running)
+    GNUNET_break (0);
   return;
 }
 
@@ -225,7 +239,7 @@
 }
 
 static void
-address_initial_update (void *solver,
+perf_address_initial_update (void *solver,
     struct GNUNET_CONTAINER_MultiPeerMap * addresses,
     struct ATS_Address *address)
 {
@@ -241,7 +255,7 @@
 }
 
 static void
-update_addresses (unsigned int cp, unsigned int ca, unsigned int up_q)
+perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int up_q)
 {
   struct ATS_Address *cur;
   int c_peer;
@@ -274,7 +288,7 @@
     for (cur = ph.peers[c_peer].head; NULL != cur; cur = cur->next)
     {
       if (1 == m[c_addr])
-        update_single_addresses (cur);
+        perf_update_address (cur);
       c_addr++;
     }
   }
@@ -302,8 +316,11 @@
   int ca;
   int count_p = ph.N_peers_end;
   int count_a = ph.N_address;
-  int bulk_running;
   struct ATS_Address * cur_addr;
+  struct GNUNET_TIME_Absolute start;
+  struct GNUNET_TIME_Absolute end;
+  struct GNUNET_TIME_Relative delta;
+
   ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
 
   for (cp = 0; cp < count_p; cp++)
@@ -313,39 +330,50 @@
 
   /* Set initial bulk start to not solve */
   ph.env.sf.s_bulk_start (ph.solver);
-  bulk_running = GNUNET_YES;
+  ph.bulk_running = GNUNET_YES;
 
   for (cp = 0; cp < count_p; cp++)
   {
     for (ca = 0; ca < count_a; ca++)
     {
       cur_addr = perf_create_address (cp, ca);
-      /* add address */
+      /* Add address */
       ph.env.sf.s_add (ph.solver, cur_addr, GNUNET_ATS_NET_LAN);
-      address_initial_update (ph.solver, ph.addresses, cur_addr);
+      perf_address_initial_update (ph.solver, ph.addresses, cur_addr);
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Adding address for peer %u address %u\n", cp, ca);
     }
+    /* Notify solver about request */
     ph.env.sf.s_get (ph.solver, &ph.peers[cp].id);
 
     if (cp + 1 >= ph.N_peers_start)
     {
       /* Disable bulk to solve the problem */
-      if (GNUNET_YES == bulk_running)
+      if (GNUNET_YES == ph.bulk_running)
       {
+        start = GNUNET_TIME_absolute_get();
+        ph.bulk_running = GNUNET_NO;
         ph.env.sf.s_bulk_stop (ph.solver);
-        bulk_running = GNUNET_NO;
       }
+      else
+      {
+        GNUNET_break (0);
+      }
 
-      /* Problem should be solved here */
+      /* Problem is solved by the solver here due to unlocking */
 
       /* Disable bulk to solve the problem */
-      if (GNUNET_NO == bulk_running)
+      if (GNUNET_NO == ph.bulk_running)
       {
+
+        end = GNUNET_TIME_absolute_get();
+        delta = GNUNET_TIME_absolute_get_difference(start, end);
+        fprintf (stderr, "Solver took %llu us to solve problem with %u peers 
and %u addresses per peer\n",
+            (unsigned long long) delta.rel_value_us,
+            cp + 1, ca);
         ph.env.sf.s_bulk_start (ph.solver);
-        bulk_running = GNUNET_YES;
+        ph.bulk_running = GNUNET_YES;
       }
-
 #if 0
       if ((0 < ph.opt_update_quantity) || (0 < ph.opt_update_percent))
       {
@@ -361,10 +389,10 @@
   }
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
       "Done, cleaning up addresses\n");
-  if (GNUNET_NO == bulk_running)
+  if (GNUNET_NO == ph.bulk_running)
   {
     ph.env.sf.s_bulk_start (ph.solver);
-    bulk_running = GNUNET_YES;
+    ph.bulk_running = GNUNET_YES;
   }
 
   for (cp = 0; cp < count_p; cp++)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]