gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 103/164: Fixed some phase stuff and shuffle full sending elemen


From: gnunet
Subject: [gnunet] 103/164: Fixed some phase stuff and shuffle full sending elements
Date: Fri, 30 Jul 2021 15:32:49 +0200

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

grothoff pushed a commit to branch master
in repository gnunet.

commit be75a8e68c3bfdc3aae18a03b7baa328889fe095
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Sat May 22 12:52:21 2021 +0200

    Fixed some phase stuff and shuffle full sending elements
---
 src/setu/gnunet-service-setu.c | 111 ++++++++++++++++++++++++-----------------
 src/setu/perf_setu_api.c       |  10 ++--
 2 files changed, 72 insertions(+), 49 deletions(-)

diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index ee1283de9..dc00cf96c 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -502,7 +502,7 @@ struct Operation
     /**
      * is
      */
-     uint64_t number_received_full_elements;
+     uint8_t differential_sync_iterations;
 };
 
 
@@ -517,6 +517,11 @@ struct SetContent
    */
   struct GNUNET_CONTAINER_MultiHashMap *elements;
 
+  /**
+   * Maps `struct GNUNET_HashCode *` to `struct ElementEntry *` randomized.
+   */
+  struct GNUNET_CONTAINER_MultiHashMap *elements_randomized;
+
   /**
    * Number of references to the content.
    */
@@ -789,26 +794,6 @@ struct message_control_flow_element
     enum MESSAGE_CONTROL_FLOW_STATE element;
 };
 
-/*
- * 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 | 1;
-    }
-     **/
-    return IBF_MIN_SIZE | 1;
-}
 
 
 static void
@@ -1108,7 +1093,7 @@ is_message_in_message_control_flow(struct 
GNUNET_CONTAINER_MultiHashMap *hash_ma
 
 
 /**
- * Iterator for determinating if all demands have been
+ * Iterator for determining if all demands have been
  * satisfied
  *
  * @param cls the union operation `struct Operation *`
@@ -1125,10 +1110,7 @@ determinate_done_message_iterator (void *cls,
     struct Operation *op = cls;
     struct message_control_flow_element *mcfe = value;
 
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "MAP FOUND: %u, %u, %u\n", mcfe->demand, mcfe->offer, mcfe->element);
-
-    if((mcfe->demand == MESSAGE_SENT || mcfe->demand == MESSAGE_RECEIVED)) {
+    if((mcfe->element == MESSAGE_SENT || mcfe->element == MESSAGE_RECEIVED)) {
         return GNUNET_YES;
     }
     return GNUNET_NO;
@@ -1155,6 +1137,34 @@ determinate_avg_element_size_iterator (void *cls,
     return GNUNET_YES;
 }
 
+/**
+ * Create randomized element hashmap for full sending
+ *
+ * @param cls the union operation `struct Operation *`
+ * @param key unused
+ * @param value the `struct ElementEntry *` to insert
+ *        into the key-to-element mapping
+ * @return #GNUNET_YES (to continue iterating)
+ */
+static int
+create_randomized_element_iterator (void *cls,
+                                       const struct GNUNET_HashCode *key,
+                                       void *value)
+{
+    struct Operation *op = cls;
+    struct GNUNET_SETU_Element *element = value;
+
+    struct GNUNET_HashContext *hashed_key_context = 
GNUNET_CRYPTO_hash_context_start ();
+    struct GNUNET_HashCode *new_key = (struct GNUNET_HashCode*) 
GNUNET_malloc(sizeof(struct GNUNET_HashCode));
+    GNUNET_CRYPTO_hash_context_read (hashed_key_context,
+                                     &key,
+                                     sizeof(struct IBF_Key));
+    GNUNET_CRYPTO_hash_context_finish (hashed_key_context,
+                                       new_key);
+    
GNUNET_CONTAINER_multihashmap_put(op->set->content->elements_randomized,new_key,value,GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
+    return GNUNET_YES;
+}
+
 /**
  * Iterator over hash map entries, called to
  * destroy the linked list of colliding ibf key entries.
@@ -1715,11 +1725,12 @@ send_ibf (struct Operation *op,
 {
   uint64_t buckets_sent = 0;
   struct InvertibleBloomFilter *ibf;
+  op->differential_sync_iterations++;
 
     /**
      * Enforce min size of IBF
      */
-    uint32_t ibf_min_size = calculate_min_buckets(op);
+    uint32_t ibf_min_size = IBF_MIN_SIZE | 1;
 
     if(ibf_size < ibf_min_size) {
         ibf_size=ibf_min_size;
@@ -1858,7 +1869,14 @@ send_full_set (struct Operation *op)
        "Dedicing to transmit the full set\n");
   /* FIXME: use a more memory-friendly way of doing this with an
      iterator, just as we do in the non-full case! */
+
+  // Randomize Elements to send
+  op->set->content->elements_randomized = 
GNUNET_CONTAINER_multihashmap_create(32,GNUNET_NO);
   (void) GNUNET_CONTAINER_multihashmap_iterate (op->set->content->elements,
+                                                  
&create_randomized_element_iterator,
+                                                  op);
+
+  (void) GNUNET_CONTAINER_multihashmap_iterate 
(op->set->content->elements_randomized,
                                                 &send_full_element_iterator,
                                                 op);
   perf_rtt.full_done.sent += 1;
@@ -2274,18 +2292,11 @@ decode_and_send (struct Operation *op)
     if ((GNUNET_SYSERR == res) ||
         (GNUNET_YES == cycle_detected))
     {
-
-      /** LOG FAILURE POINT **/
-      FILE *out1 = fopen("when_decoding_failed.csv", "a");
-      fprintf(out1, "%d\n", num_decoded);
-      fclose(out1);
-
-
-        uint32_t next_size;
+      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);
+      uint32_t ibf_min_size = IBF_MIN_SIZE | 1;
 
       if(next_size<ibf_min_size)
           next_size=ibf_min_size;
@@ -2365,7 +2376,7 @@ decode_and_send (struct Operation *op)
 
       /** Add sent inquiries to hashmap for flow control **/
       struct GNUNET_HashContext *hashed_key_context = 
GNUNET_CRYPTO_hash_context_start ();
-      struct GNUNET_HashCode *hashed_key = (struct GNUNET_HashCode*) 
GNUNET_malloc(sizeof(struct GNUNET_HashCode));;
+      struct GNUNET_HashCode *hashed_key = (struct GNUNET_HashCode*) 
GNUNET_malloc(sizeof(struct GNUNET_HashCode));
       enum MESSAGE_CONTROL_FLOW_STATE mcfs = MESSAGE_SENT;
       GNUNET_CRYPTO_hash_context_read (hashed_key_context,
                                       &key,
@@ -2488,6 +2499,11 @@ handle_union_p2p_ibf (void *cls,
         fail_union_operation (op);
         return;
     }
+  op->differential_sync_iterations++;
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "XXXXXXXXXXXXXXXXXX %u\n", op->differential_sync_iterations);
+
+
 
   perf_rtt.ibf.received += 1;
   perf_rtt.ibf.received_var_bytes += (ntohs (msg->header.size) - sizeof *msg);
@@ -2610,13 +2626,16 @@ maybe_finish (struct Operation *op)
 
   num_demanded = GNUNET_CONTAINER_multihashmap_size (
     op->demanded_hashes);
+  unsigned int send_done  =  GNUNET_CONTAINER_multihashmap_iterate 
(op->message_control_flow,
+                                                          
&determinate_done_message_iterator,
+                                                          op);
 
   if (PHASE_FINISH_WAITING == op->phase)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "In PHASE_FINISH_WAITING, pending %u demands\n",
-         num_demanded);
-    if (0 == num_demanded)
+         "In PHASE_FINISH_WAITING, pending %u demands -> %d\n",
+         num_demanded, op->peer_site);
+    if (GNUNET_OK == send_done)
     {
       struct GNUNET_MQ_Envelope *ev;
 
@@ -2632,9 +2651,9 @@ maybe_finish (struct Operation *op)
   if (PHASE_FINISH_CLOSING == op->phase)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "In PHASE_FINISH_CLOSING, pending %u demands\n",
-         num_demanded);
-    if (0 == num_demanded)
+         "In PHASE_FINISH_CLOSING, pending %u demands %d\n",
+         num_demanded, op->peer_site);
+    if (GNUNET_OK == send_done)
     {
       op->phase = PHASE_FINISHED;
       send_client_done (op);
@@ -3202,7 +3221,7 @@ handle_union_p2p_demand (void *cls,
     /**
     * Check that the message is received only in supported phase
     */
-    uint8_t allowed_phases[] = {PHASE_ACTIVE_DECODING, PHASE_PASSIVE_DECODING, 
PHASE_FINISH_WAITING, PHASE_FINISHED};
+    uint8_t allowed_phases[] = {PHASE_ACTIVE_DECODING, PHASE_PASSIVE_DECODING};
     if( GNUNET_OK !=
         check_valid_phase(allowed_phases,sizeof(allowed_phases),op)){
         GNUNET_break (0);
@@ -3210,7 +3229,7 @@ handle_union_p2p_demand (void *cls,
         return;
     }
 
-    perf_rtt.demand.received += 1;
+  perf_rtt.demand.received += 1;
   perf_rtt.demand.received_var_bytes += (ntohs (mh->size) - sizeof(struct 
GNUNET_MessageHeader));
 
   num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader))
@@ -3471,7 +3490,7 @@ handle_union_p2p_done (void *cls,
   /**
   * Check that the message is received only in supported phase
   */
-  uint8_t allowed_phases[] = {PHASE_ACTIVE_DECODING, PHASE_PASSIVE_DECODING};
+  uint8_t allowed_phases[] = {PHASE_ACTIVE_DECODING, PHASE_FINISH_WAITING};
   if( GNUNET_OK !=
     check_valid_phase(allowed_phases,sizeof(allowed_phases),op)){
     GNUNET_break (0);
diff --git a/src/setu/perf_setu_api.c b/src/setu/perf_setu_api.c
index ac02239df..b613cb84e 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(2900, 3000,3000,32);
+    initRandomSets(5, 10,10,32);
 }
 
 void perf_thread() {
@@ -425,6 +425,10 @@ static void run_petf_thread(int total_runs) {
 //Father code (before child processes start)
     for (int processed = 0; processed < total_runs;) {
         for (int id = 0; id < core_count; id++) {
+            perf_thread();
+            processed += 1;
+        }
+            /**
             if(processed >= total_runs) break;
 
             if ((child_pid = fork()) == 0) {
@@ -433,7 +437,7 @@ static void run_petf_thread(int total_runs) {
             }
             processed += 1;
         }
-        while ((wpid = wait(&status)) > 0);
+        while ((wpid = wait(&status)) > 0); **/
     }
 }
 
@@ -456,7 +460,7 @@ static void execute_perf() {
             gcvt(x, 4, factor);
 
             char tradeoff[10] = "200000";
-            if((full_diff_ctr % 2) == 0) {
+            if((full_diff_ctr % 2) == 1) {
                 gcvt(0.25, 4, tradeoff);
             } else {
 

-- 
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]