gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 03/164: Added multitreading


From: gnunet
Subject: [gnunet] 03/164: Added multitreading
Date: Fri, 30 Jul 2021 15:31:09 +0200

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

grothoff pushed a commit to branch master
in repository gnunet.

commit 3be16a6d72348a74e9fda9299fc22581caa250bb
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Sat Apr 3 18:56:04 2021 +0200

    Added multitreading
---
 src/setu/gnunet-service-setu.c | 25 +++++++++++---
 src/setu/perf_setu_api.c       | 77 +++++++++++++++++++++++++++++-------------
 2 files changed, 75 insertions(+), 27 deletions(-)

diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index 6d0693524..1d648748b 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -783,12 +783,29 @@ calculate_perf_rtt() {
     LOG(GNUNET_ERROR_TYPE_ERROR,"Estimateded set difference: %d\n", 
perf_rtt.se_diff);
 
 
+    /*
+     * Write IBF failure rate for different BUCKET_NUMBER_FACTOR
+     */
+    float factor;
+    GNUNET_CONFIGURATION_get_value_float(setu_cfg,"IBF", 
"BUCKET_NUMBER_FACTOR", &factor);
+    int num_per_bucket;
+    GNUNET_CONFIGURATION_get_value_number(setu_cfg,"IBF", "NUMBER_PER_BUCKET", 
&num_per_bucket);
+
+    int decoded = 0;
+    if(perf_rtt.active_passive_switches == 0)
+        decoded = 1;
+
+    FILE *out1 = fopen("perf_failure_bucket_number_factor.csv", "a");
+    fprintf(out1, "%d,%f,%d\n",num_per_bucket,factor,decoded);
+    fclose(out1);
+
 
     /**
-     * Write performance csv output
-     * <se_diff>,<active_passive_switches>,<bytes_transmitted>,<rtt>
-     */
-    FILE *out = fopen("perfstats.log", "a");
+    * Write performance csv output
+    * <se_diff>,<active_passive_switches>,<bytes_transmitted>,<rtt>
+    */
+
+    FILE *out = fopen("perf_stats.csv", "a");
     fprintf(out, "%d,%d,%d,%f\n", perf_rtt.se_diff, 
perf_rtt.active_passive_switches,bytes_transmitted,rtt);
     fclose(out);
     return 0;
diff --git a/src/setu/perf_setu_api.c b/src/setu/perf_setu_api.c
index a0e5ba279..aa1f9ed19 100644
--- a/src/setu/perf_setu_api.c
+++ b/src/setu/perf_setu_api.c
@@ -27,6 +27,8 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_testing_lib.h"
 #include "gnunet_setu_service.h"
+#include <sys/sysinfo.h>
+#include <pthread.h>
 
 
 static struct GNUNET_PeerIdentity local_id;
@@ -405,36 +407,65 @@ run (void *cls,
     initRandomSets(450,500,500,32);
 }
 
-static void execute_perf()
-{
-    setu_cfg =  GNUNET_CONFIGURATION_create ();
-    GNUNET_CONFIGURATION_set_value_string (setu_cfg, "IBF", 
"BUCKET_NUMBER_FACTOR", "1"); // Factor default=4
-    GNUNET_CONFIGURATION_set_value_number (setu_cfg, "IBF", 
"NUMBER_PER_BUCKET", 4); // K default=4
-    GNUNET_CONFIGURATION_set_value_string (setu_cfg, "PERFORMANCE", 
"TRADEOFF", "0.25");
-    GNUNET_CONFIGURATION_set_value_string (setu_cfg, "PERFORMANCE", 
"MAX_SET_DIFF_FACTOR_DIFFERENTIAL", "0.25"); //default=4
+static void perf_thread(void *arg) {
+    GNUNET_TESTING_service_run("perf_setu_api",
+                               "arm",
+                               "test_setu.conf",
+                               &run,
+                               NULL);
+    return NULL;
+}
+
+
+static void run_petf_thread(int total_runs) {
+    int core_count=get_nprocs_conf();
+    for(int runs = 0; runs < total_runs; runs += core_count) {
+        pthread_t tid[core_count];
+
+        for (int i = 0; i < core_count; i++) {
+            pthread_create(&tid[i], NULL, perf_thread, NULL);
+        }
+
+        for (int i = 0; i < core_count; i++)
+            pthread_join(tid[i], NULL);
+    }
+
+}
+
+static void execute_perf() {
 
     /**
-     * Erase statfile
-     */
-     remove("perfstats.log");
+    * Erase statfile
+    */
+    remove("perf_stats.csv");
+    remove("perf_failure_bucket_number_factor.csv");
     //FILE *out = fopen("perfstats.log", "w");
     //fprintf(out, "se_diff,active_passive_switches,bytes_transmitted,rtt\n");
 
-    if (GNUNET_OK != GNUNET_CONFIGURATION_write (setu_cfg, 
"/tmp/perf_setu.conf"))
-        GNUNET_log (
-            GNUNET_ERROR_TYPE_ERROR,
-                _ ("Failed to write subsystem default identifier map to 
`%s'.\n"),
-                setu_cfg);
-    for( int repeat_ctr = 0; repeat_ctr<100; repeat_ctr++ ) {
+    for (int out_out_ctr = 1; out_out_ctr <= 10; out_out_ctr++) {
 
-        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "Executing perf round %d\n", repeat_ctr);
+        for (int out_ctr = 0; out_ctr <= 100; out_ctr++) {
 
-        GNUNET_TESTING_service_run ("perf_setu_api",
-                                 "arm",
-                                 "test_setu.conf",
-                                 &run,
-                                 NULL);
+            float base = 0.1;
+            float x = out_ctr * base;
+            char factor[10];
+            gcvt(x, 4, factor);
+
+            setu_cfg = GNUNET_CONFIGURATION_create();
+            GNUNET_CONFIGURATION_set_value_string(setu_cfg, "IBF", 
"BUCKET_NUMBER_FACTOR", factor); // Factor default=4
+            GNUNET_CONFIGURATION_set_value_number(setu_cfg, "IBF", 
"NUMBER_PER_BUCKET", out_out_ctr); // K default=4
+            GNUNET_CONFIGURATION_set_value_string(setu_cfg, "PERFORMANCE", 
"TRADEOFF", "0.25");
+            GNUNET_CONFIGURATION_set_value_string(setu_cfg, "PERFORMANCE", 
"MAX_SET_DIFF_FACTOR_DIFFERENTIAL",
+                                                  "0.25");//default=4
+
+
+            if (GNUNET_OK != GNUNET_CONFIGURATION_write(setu_cfg, 
"/tmp/perf_setu.conf"))
+                GNUNET_log(
+                        GNUNET_ERROR_TYPE_ERROR,
+                        _("Failed to write subsystem default identifier map to 
`%s'.\n"),
+                        setu_cfg);
+            run_petf_thread(100);
+        }
     }
     return 0;
 }

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