summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Summermatter <elias.summermatter@seccom.ch>2021-04-03 18:56:04 +0200
committerElias Summermatter <elias.summermatter@seccom.ch>2021-04-03 18:56:04 +0200
commit70924855f4946fab84bf2ca58f643bdd2dd4fc77 (patch)
tree1dbb753aa90bee76712d708f6ae387c9a8baa875
parent265bdcd1370e1764d538184040edbb380e6fbf93 (diff)
Added multitreading
-rw-r--r--src/setu/gnunet-service-setu.c25
-rw-r--r--src/setu/perf_setu_api.c77
2 files changed, 75 insertions, 27 deletions
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index fb1c9a99d..d13285a69 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 a2fea6ff4..de9eb8c0d 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;
}