gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 49/164: Added MIN IBF Size auto increase depended on totalsetsi


From: gnunet
Subject: [gnunet] 49/164: Added MIN IBF Size auto increase depended on totalsetsize + added missing remote/local element count to op
Date: Fri, 30 Jul 2021 15:31:55 +0200

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

grothoff pushed a commit to branch master
in repository gnunet.

commit add22ee67f328e57af2998bcef932c2fd5021e47
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Wed Apr 21 16:21:59 2021 +0200

    Added MIN IBF Size auto increase depended on totalsetsize + added missing 
remote/local element count to op
---
 src/set/ibf.h                  |  3 +++
 src/setu/gnunet-service-setu.c | 47 +++++++++++++++++++++++++++++++++++-------
 src/setu/ibf.c                 |  3 +++
 src/setu/perf_setu_api.c       |  4 ++--
 4 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/src/set/ibf.h b/src/set/ibf.h
index 7c2ab33b1..d6af2c55c 100644
--- a/src/set/ibf.h
+++ b/src/set/ibf.h
@@ -244,6 +244,9 @@ ibf_dup (const struct InvertibleBloomFilter *ibf);
 void
 ibf_destroy (struct InvertibleBloomFilter *ibf);
 
+void
+ibf_check_overflown_buckets(struct InvertibleBloomFilter *ibf )
+
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index e49770173..94bb43230 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -82,7 +82,7 @@
 /**
  * Minimal size of an ibf
  */
-#define IBF_MIN_SIZE 32
+#define IBF_MIN_SIZE 36
 
 
 /**
@@ -445,6 +445,10 @@ struct Operation
 
    unsigned int active_passive_switches;
 
+   /*
+    * Local peer element count
+    */
+    uint32_t local_element_count;
 };
 
 
@@ -706,7 +710,25 @@ struct perf_rtt_struct
 struct perf_rtt_struct perf_rtt;
 
 
+/*
+ * Calcuate
+ */
+uint32_t
+calculate_min_buckets(struct Operation *op)
+{
+    // Save local set size
+    if(0 == op->local_element_count) {
+        op->local_element_count = GNUNET_CONTAINER_multihashmap_size (
+                op->set->content->elements);
+    }
+    uint16_t bits_per_counter = 128;
+    uint32_t calculated_min=((op->remote_element_count + 
op->local_element_count) * 5) / bits_per_counter;
+    if(calculated_min >= IBF_MIN_SIZE) {
+        return calculated_min;
+    }
+    return IBF_MIN_SIZE | 1;
 
+}
 
 
 static void
@@ -1394,6 +1416,14 @@ send_ibf (struct Operation *op,
   unsigned int buckets_sent = 0;
   struct InvertibleBloomFilter *ibf;
 
+    /**
+     * Enforce min size of IBF
+     */
+    uint32_t ibf_min_size = calculate_min_buckets(op);
+
+    if(ibf_size < ibf_min_size) {
+        ibf_size=ibf_min_size;
+    }
   if (GNUNET_OK !=
       prepare_ibf (op, ibf_size))
   {
@@ -1469,12 +1499,6 @@ static unsigned int
 get_next_ibf_size(float ibf_bucket_number_factor, unsigned int 
decoded_elements, unsigned int last_ibf_size )
 {
     unsigned int next_size = (unsigned int) ((last_ibf_size * 2) - ( 
ibf_bucket_number_factor * decoded_elements ));
-
-    if(next_size > MAX_IBF_SIZE)
-        next_size = MAX_IBF_SIZE;
-
-    if(next_size < IBF_MIN_SIZE)
-        next_size = IBF_MIN_SIZE;
     return next_size | 1;
 }
 
@@ -1603,6 +1627,7 @@ handle_union_p2p_strata_estimator (void *cls,
                             GNUNET_NO);
   len = ntohs (msg->header.size) - sizeof(struct StrataEstimatorMessage);
   other_size = GNUNET_ntohll (msg->set_size);
+  op->remote_element_count = other_size;
   remote_se = strata_estimator_create (SE_STRATA_COUNT,
                                        SE_IBF_SIZE,
                                        SE_IBF_HASH_NUM);
@@ -1807,6 +1832,8 @@ decode_and_send (struct Operation *op)
     /* allocation failed */
     return GNUNET_SYSERR;
   }
+  ibf_check_overflown_buckets(op->remote_ibf);
+
   diff_ibf = ibf_dup (op->local_ibf);
   ibf_subtract (diff_ibf,
                 op->remote_ibf);
@@ -1854,8 +1881,12 @@ decode_and_send (struct Operation *op)
       uint32_t next_size;
       /** Enforce odd ibf size **/
 
-
       next_size = get_next_ibf_size(op->ibf_bucket_number_factor, num_decoded, 
diff_ibf->size);
+      uint32_t ibf_min_size = calculate_min_buckets(op);
+
+      if(next_size<ibf_min_size)
+          next_size=ibf_min_size;
+
 
       if (next_size <= MAX_IBF_SIZE)
       {
diff --git a/src/setu/ibf.c b/src/setu/ibf.c
index 1beba9065..36138f856 100644
--- a/src/setu/ibf.c
+++ b/src/setu/ibf.c
@@ -25,6 +25,9 @@
  */
 
 #include "ibf.h"
+#include "gnunet_util_lib.h"
+#define LOG(kind, ...) GNUNET_log_from (kind, "setu", __VA_ARGS__)
+
 
 /**
  * Compute the key's hash from the key.
diff --git a/src/setu/perf_setu_api.c b/src/setu/perf_setu_api.c
index 2b7aa1e69..76355b6ba 100644
--- a/src/setu/perf_setu_api.c
+++ b/src/setu/perf_setu_api.c
@@ -404,7 +404,7 @@ run (void *cls,
                 "Running real set-reconciliation\n");
     //init_set1 ();
     // limit ~23800 element total
-    initRandomSets(4500,5000,5000,32);
+    initRandomSets(4000,5000,5000,32);
 }
 
 void perf_thread() {
@@ -449,7 +449,7 @@ static void execute_perf() {
 
     for (int out_out_ctr = 3; out_out_ctr <= 3; out_out_ctr++) {
 
-        for (int out_ctr = 15; out_ctr <= 50; out_ctr++) {
+        for (int out_ctr = 20; out_ctr <= 20; out_ctr++) {
             float base = 0.1;
             float x = out_ctr * base;
             char factor[10];

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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