gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (c420d3cda -> 9d0685805)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (c420d3cda -> 9d0685805)
Date: Wed, 21 Mar 2018 10:12:55 +0100

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a change to branch master
in repository gnunet.

    from c420d3cda name
     new 28e2cbb91 rps: logging
     new 29d419cdf rps profiler: restructure function
     new 9d0685805 rps profiler: log view sizes

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/rps/gnunet-service-rps.c |  5 ++++
 src/rps/rps-test_util.c      | 18 +++++++++--
 src/rps/rps_api.c            |  3 ++
 src/rps/test_rps.c           | 71 ++++++++++++++++++++++++++++++++++----------
 4 files changed, 78 insertions(+), 19 deletions(-)

diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index fabef9388..30d677849 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -3848,6 +3848,11 @@ do_round (void *cls)
                                 CustomPeerMap_size (pull_map));
     final_size    = second_border +
       ceil ((1 - (alpha + beta)) * view_size_est_need);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "first border: %" PRIu32 ", second border: %" PRIu32 ", final size: 
%"PRIu32 "\n",
+        first_border,
+        second_border,
+        final_size);
 
     /* Update view with peers received through PUSHes */
     permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG,
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 882f945c9..e492b76b7 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -43,6 +43,7 @@ to_file_ (char *file_name, char *line)
 {
   struct GNUNET_DISK_FileHandle *f;
   char output_buffer[512];
+  char *output_buffer_p;
   //size_t size;
   int size;
   size_t size2;
@@ -62,8 +63,14 @@ to_file_ (char *file_name, char *line)
          file_name);
     return;
   }
-  size = GNUNET_snprintf (output_buffer,
-                          sizeof (output_buffer),
+  if (512 < strlen (line) + 18)
+  {
+    output_buffer_p = GNUNET_malloc ((strlen (line) + 18) * sizeof (char));
+  } else {
+    output_buffer_p = &output_buffer[0];
+  }
+  size = GNUNET_snprintf (output_buffer_p,
+                          sizeof (output_buffer_p),
                           "%llu %s\n",
                           GNUNET_TIME_absolute_get ().abs_value_us,
                           line);
@@ -75,7 +82,7 @@ to_file_ (char *file_name, char *line)
     return;
   }
 
-  size2 = GNUNET_DISK_file_write (f, output_buffer, size);
+  size2 = GNUNET_DISK_file_write (f, output_buffer_p, size);
   if (size != size2)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -90,6 +97,11 @@ to_file_ (char *file_name, char *line)
     return;
   }
 
+  if (512 < strlen (line) + 18)
+  {
+    GNUNET_free (output_buffer_p);
+  }
+
   if (GNUNET_YES != GNUNET_DISK_file_close (f))
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "Unable to close file\n");
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 62ba9e226..0da3bd4a4 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -266,6 +266,9 @@ GNUNET_RPS_view_request (struct GNUNET_RPS_Handle 
*rps_handle,
   struct GNUNET_MQ_Envelope *ev;
   struct GNUNET_RPS_CS_DEBUG_ViewRequest *msg;
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Client requests %" PRIu32 " view updates\n",
+       num_updates);
   rps_handle->view_update_cb = view_update_cb;
   rps_handle->view_update_cls = cls;
 
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index e0f87652b..d9f0a2c77 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -1818,9 +1818,27 @@ store_stats_file_name (struct RPSPeer *rps_peer)
   rps_peer->file_name_stats = file_name;
 }
 
+void count_peer_in_views (uint32_t *count_peers)
+{
+  uint32_t i, j;
+
+  for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
+  {
+    for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
+    {
+      if (0 == memcmp (rps_peers[i].peer_id,
+            &rps_peers[i].cur_view[j],
+            sizeof (struct GNUNET_PeerIdentity)))
+      {
+        count_peers[i]++;
+      }
+    }
+  }
+}
+
 void compute_diversity ()
 {
-  uint32_t i, j, k;
+  uint32_t i;
   /* ith entry represents the numer of occurrences in other peer's views */
   uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t);
   uint32_t views_total_size;
@@ -1835,21 +1853,11 @@ void compute_diversity ()
   for (i = 0; i < num_peers; i++) /* Peer to count */
   {
     views_total_size += rps_peers[i].cur_view_count;
-    for (j = 0; j < num_peers; j++) /* Peer in which view is counted */
-    {
-      for (k = 0; k < rps_peers[j].cur_view_count; k++) /* entry in view */
-      {
-        if (0 == memcmp (rps_peers[i].peer_id,
-                         &rps_peers[j].cur_view[k],
-                         sizeof (struct GNUNET_PeerIdentity)))
-        {
-          count_peers[i]++;
-        }
-      }
-    }
+    count_peer_in_views (count_peers);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Counted representation of %" PRIu32 "th peer: %" PRIu32"\n",
+               "Counted representation of %" PRIu32 "th peer [%s]: %" 
PRIu32"\n",
                i,
+               GNUNET_i2s (rps_peers[i].peer_id),
                count_peers[i]);
   }
 
@@ -1870,9 +1878,40 @@ void compute_diversity ()
   GNUNET_free (deviation);
 }
 
-void all_views_updated_cb ()
+void print_view_sizes()
+{
+  uint32_t i;
+  char *view_sizes_str = NULL;
+  uint32_t view_sizes_str_len = 0;
+  char view_size_curr[32] = { 0 };
+
+  GNUNET_array_grow (view_sizes_str, view_sizes_str_len, num_peers * 3);
+  for (i = 0; i < num_peers; i++) /* Peer to count */
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
+               i,
+               GNUNET_i2s (rps_peers[i].peer_id),
+               rps_peers[i].cur_view_count);
+    GNUNET_snprintf (view_size_curr,
+                     sizeof (view_size_curr),
+                     " %" PRIu32 "",
+                     rps_peers[i].cur_view_count);
+    if (view_sizes_str_len < view_sizes_str_len + strlen (view_size_curr))
+    {
+      GNUNET_array_grow (view_sizes_str, view_sizes_str_len, 
view_sizes_str_len + 10);
+    }
+    strncat (view_sizes_str, view_size_curr, strlen(view_size_curr));
+  }
+  to_file_ ("/tmp/rps/view_sizes.txt",
+           view_sizes_str);
+  GNUNET_array_grow (view_sizes_str, view_sizes_str_len, 0);
+}
+
+void all_views_updated_cb()
 {
-  compute_diversity ();
+  compute_diversity();
+  print_view_sizes();
 }
 
 void view_update_cb (void *cls,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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