aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-10-31 16:25:15 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-10-31 16:25:15 +0000
commitda5c12170ab8ffa5d91a9e704a7060b79ce465fd (patch)
tree5623457c0d5760e908f0aedde972116c6c36ade7
parentccca2c88edefc822d4e8e4b81403448d14e29070 (diff)
downloadgnunet-da5c12170ab8ffa5d91a9e704a7060b79ce465fd.tar.gz
gnunet-da5c12170ab8ffa5d91a9e704a7060b79ce465fd.zip
benchmark with updates
-rw-r--r--src/ats/libgnunet_plugin_ats_mlp.c18
-rw-r--r--src/ats/perf_ats_solver.c274
-rw-r--r--src/include/gnunet_ats_plugin.h4
3 files changed, 194 insertions, 102 deletions
diff --git a/src/ats/libgnunet_plugin_ats_mlp.c b/src/ats/libgnunet_plugin_ats_mlp.c
index 5d463093e..78a00f462 100644
--- a/src/ats/libgnunet_plugin_ats_mlp.c
+++ b/src/ats/libgnunet_plugin_ats_mlp.c
@@ -1106,7 +1106,7 @@ GAS_mlp_solve_problem (void *solver)
1106 return GNUNET_NO; 1106 return GNUNET_NO;
1107 } 1107 }
1108 notify (mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS, 1108 notify (mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS,
1109 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED); 1109 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1110 1110
1111 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers)) 1111 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers))
1112 { 1112 {
@@ -1128,14 +1128,14 @@ GAS_mlp_solve_problem (void *solver)
1128 if (GNUNET_YES == mlp->mlp_prob_changed) 1128 if (GNUNET_YES == mlp->mlp_prob_changed)
1129 { 1129 {
1130 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); 1130 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
1131 notify (mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_MLP_FULL); 1131 notify (mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_FULL);
1132 mlp_delete_problem (mlp); 1132 mlp_delete_problem (mlp);
1133 if (GNUNET_SYSERR == mlp_create_problem (mlp)) 1133 if (GNUNET_SYSERR == mlp_create_problem (mlp))
1134 { 1134 {
1135 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL, GAS_INFO_MLP_FULL); 1135 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL, GAS_INFO_FULL);
1136 return GNUNET_SYSERR; 1136 return GNUNET_SYSERR;
1137 } 1137 }
1138 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_MLP_FULL); 1138 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL);
1139 mlp->control_param_lp.presolve = GLP_YES; 1139 mlp->control_param_lp.presolve = GLP_YES;
1140 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ 1140 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */
1141 } 1141 }
@@ -1147,26 +1147,26 @@ GAS_mlp_solve_problem (void *solver)
1147 /* Run LP solver */ 1147 /* Run LP solver */
1148 1148
1149 notify (mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS, 1149 notify (mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS,
1150 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED); 1150 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1151 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n", 1151 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n",
1152 (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver"); 1152 (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver");
1153 res_lp = mlp_solve_lp_problem (mlp); 1153 res_lp = mlp_solve_lp_problem (mlp);
1154 notify (mlp, GAS_OP_SOLVE_LP_STOP, 1154 notify (mlp, GAS_OP_SOLVE_LP_STOP,
1155 (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, 1155 (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
1156 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED); 1156 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1157 1157
1158 1158
1159 /* Run MLP solver */ 1159 /* Run MLP solver */
1160 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n"); 1160 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n");
1161 notify (mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS, 1161 notify (mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS,
1162 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED); 1162 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1163 res_mip = mlp_solve_mlp_problem (mlp); 1163 res_mip = mlp_solve_mlp_problem (mlp);
1164 notify (mlp, GAS_OP_SOLVE_MLP_STOP, 1164 notify (mlp, GAS_OP_SOLVE_MLP_STOP,
1165 (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, 1165 (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
1166 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED); 1166 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1167 notify (mlp, GAS_OP_SOLVE_STOP, 1167 notify (mlp, GAS_OP_SOLVE_STOP,
1168 (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, 1168 (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
1169 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_MLP_FULL : GAS_INFO_MLP_UPDATED); 1169 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1170 1170
1171 /* Save stats */ 1171 /* Save stats */
1172 mlp->ps.lp_res = res_lp; 1172 mlp->ps.lp_res = res_lp;
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index 0b0fbb1b8..ddb16fe5f 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -32,6 +32,7 @@
32#include "gnunet_ats_plugin.h" 32#include "gnunet_ats_plugin.h"
33#include "test_ats_api_common.h" 33#include "test_ats_api_common.h"
34 34
35#define DEFAULT_UPDATE_PERCENTAGE 20
35#define DEFAULT_PEERS_START 10 36#define DEFAULT_PEERS_START 10
36#define DEFAULT_PEERS_END 10 37#define DEFAULT_PEERS_END 10
37#define DEFAULT_ADDRESSES 10 38#define DEFAULT_ADDRESSES 10
@@ -44,6 +45,13 @@
44"set ylabel \"Execution time in us\" \n" \ 45"set ylabel \"Execution time in us\" \n" \
45"set grid \n" 46"set grid \n"
46 47
48#define GNUPLOT_PROP_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \
49"set datafile separator ';' \n" \
50"set title \"Execution time Proportional solver with updated problem\" \n" \
51"set xlabel \"Number of peers\" \n" \
52"set ylabel \"Execution time in us\" \n" \
53"set grid \n"
54
47#define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \ 55#define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \
48"set datafile separator ';' \n" \ 56"set datafile separator ';' \n" \
49"set title \"Execution time MLP solver \" \n" \ 57"set title \"Execution time MLP solver \" \n" \
@@ -51,6 +59,13 @@
51"set ylabel \"Execution time in us\" \n" \ 59"set ylabel \"Execution time in us\" \n" \
52"set grid \n" 60"set grid \n"
53 61
62#define GNUPLOT_MLP_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \
63"set datafile separator ';' \n" \
64"set title \"Execution time MLP solver with updated problem\" \n" \
65"set xlabel \"Number of peers\" \n" \
66"set ylabel \"Execution time in us\" \n" \
67"set grid \n"
68
54#define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \ 69#define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \
55"set datafile separator ';' \n" \ 70"set datafile separator ';' \n" \
56"set title \"Execution time RIL solver \" \n" \ 71"set title \"Execution time RIL solver \" \n" \
@@ -58,6 +73,13 @@
58"set ylabel \"Execution time in us\" \n" \ 73"set ylabel \"Execution time in us\" \n" \
59"set grid \n" 74"set grid \n"
60 75
76#define GNUPLOT_RIL_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \
77"set datafile separator ';' \n" \
78"set title \"Execution time RIL solver with updated problem\" \n" \
79"set xlabel \"Number of peers\" \n" \
80"set ylabel \"Execution time in us\" \n" \
81"set grid \n"
82
61/** 83/**
62 * Handle for ATS address component 84 * Handle for ATS address component
63 */ 85 */
@@ -128,14 +150,14 @@ struct PerfHandle
128 int opt_update_percent; 150 int opt_update_percent;
129 151
130 /** 152 /**
131 * Number of peers to update 153 * Create gnuplot file
132 */ 154 */
133 int opt_update_quantity; 155 int create_plot;
134 156
135 /** 157 /**
136 * Create gnuplot file 158 * Measure updates
137 */ 159 */
138 int create_plot; 160 int measure_updates;
139 161
140 /** 162 /**
141 * Is a bulk operation running? 163 * Is a bulk operation running?
@@ -155,6 +177,7 @@ struct Result
155 177
156 int peers; 178 int peers;
157 int addresses; 179 int addresses;
180 int update;
158 181
159 enum GAS_Solver_Additional_Information info; 182 enum GAS_Solver_Additional_Information info;
160 183
@@ -244,7 +267,7 @@ perf_update_address (struct ATS_Address *cur)
244 { 267 {
245 case 0: 268 case 0:
246 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); 269 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100);
247 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 270 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
248 "Updating peer `%s' address %p type %s val %u\n", 271 "Updating peer `%s' address %p type %s val %u\n",
249 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val); 272 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val);
250 ph.env.sf.s_address_update_property (ph.solver, cur, 273 ph.env.sf.s_address_update_property (ph.solver, cur,
@@ -254,7 +277,7 @@ perf_update_address (struct ATS_Address *cur)
254 case 1: 277 case 1:
255 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10); 278 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10);
256 279
257 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 280 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
258 "Updating peer `%s' address %p type %s val %u\n", 281 "Updating peer `%s' address %p type %s val %u\n",
259 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val); 282 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val);
260 ph.env.sf.s_address_update_property (ph.solver, cur, 283 ph.env.sf.s_address_update_property (ph.solver, cur,
@@ -324,41 +347,53 @@ perf_address_initial_update (void *solver,
324} 347}
325 348
326static void 349static void
327perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int up_q) 350perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers)
328{ 351{
329 struct ATS_Address *cur; 352 struct ATS_Address *cur_address;
330 int c_peer; 353 int c_peer;
331 int c_select; 354 int c_select;
332 int c_addr; 355 int c_cur_p;
356 int c_cur_a;
333 int r; 357 int r;
358 int count;
359 unsigned int m[cp];
334 360
335 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 361 count = cp * ((double) percentage_peers / 100);
336 "Updating addresses %u addresses per peer \n", up_q); 362 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
337 unsigned int m[ca]; 363 "Updating %u of %u peers \n", count, cp);
338 364
339 for (c_peer = 0; c_peer < cp; c_peer++) 365 for (c_peer = 0; c_peer < cp; c_peer++)
366 m[c_peer] = 0;
367
368 c_select = 0;
369
370 while (c_select < count)
371 {
372 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, cp);
373 if (0 == m[r])
374 {
375 m[r] = 1;
376 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
377 "Updating peer [%u] \n", r);
378 c_select++;
379 }
380 }
381 for (c_cur_p = 0; c_cur_p < cp; c_cur_p++)
340 { 382 {
341 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s'\n", 383 if (1 == m[c_cur_p])
342 GNUNET_i2s (&ph.peers[c_peer].id));
343 for (c_select = 0; c_select < ca; c_select++)
344 m[c_select] = 0;
345 c_select = 0;
346 while (c_select < ph.opt_update_quantity)
347 { 384 {
348 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca); 385 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca);
349 if (0 == m[r]) 386 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
387 "Updating peer [%u] address [%u]\n", c_cur_p, r);
388
389 c_cur_a = 0;
390 for (cur_address = ph.peers[c_cur_p].head; NULL != cur_address; cur_address = cur_address->next)
350 { 391 {
351 m[r] = 1; 392 if (c_cur_a == r)
352 c_select++; 393 perf_update_address (cur_address);
353 }
354 }
355 394
356 c_addr = 0; 395 c_cur_a ++;
357 for (cur = ph.peers[c_peer].head; NULL != cur; cur = cur->next) 396 }
358 {
359 if (1 == m[c_addr])
360 perf_update_address (cur);
361 c_addr++;
362 } 397 }
363 } 398 }
364} 399}
@@ -387,10 +422,10 @@ solver_info_cb (void *cls,
387 case GAS_INFO_NONE: 422 case GAS_INFO_NONE:
388 add_info = "GAS_INFO_NONE"; 423 add_info = "GAS_INFO_NONE";
389 break; 424 break;
390 case GAS_INFO_MLP_FULL: 425 case GAS_INFO_FULL:
391 add_info = "GAS_INFO_MLP_FULL"; 426 add_info = "GAS_INFO_MLP_FULL";
392 break; 427 break;
393 case GAS_INFO_MLP_UPDATED: 428 case GAS_INFO_UPDATED:
394 add_info = "GAS_INFO_MLP_UPDATED"; 429 add_info = "GAS_INFO_MLP_UPDATED";
395 break; 430 break;
396 case GAS_INFO_PROP_ALL: 431 case GAS_INFO_PROP_ALL:
@@ -431,6 +466,10 @@ solver_info_cb (void *cls,
431 ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL; 466 ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL;
432 ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL; 467 ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL;
433 ph.current_result->info = add; 468 ph.current_result->info = add;
469 if (add == GAS_INFO_UPDATED)
470 ph.current_result->update = GNUNET_YES;
471 else
472 ph.current_result->update = GNUNET_NO;
434 } 473 }
435 return; 474 return;
436 case GAS_OP_SOLVE_STOP: 475 case GAS_OP_SOLVE_STOP:
@@ -526,7 +565,7 @@ solver_info_cb (void *cls,
526 } 565 }
527 ph.current_result->e_mlp = GNUNET_TIME_absolute_get (); 566 ph.current_result->e_mlp = GNUNET_TIME_absolute_get ();
528 ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference ( 567 ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference (
529 ph.current_result->s_mlp, ph.current_result->e_mlp); 568 ph.current_result->s_mlp, ph.current_result->e_mlp);
530 return; 569 return;
531 570
532 default: 571 default:
@@ -535,14 +574,17 @@ solver_info_cb (void *cls,
535} 574}
536 575
537static void 576static void
538write_gnuplot_script (char * data_fn) 577write_gnuplot_script (char * data_fn, int full)
539{ 578{
540 struct GNUNET_DISK_FileHandle *f; 579 struct GNUNET_DISK_FileHandle *f;
541 char * gfn; 580 char * gfn;
542 char *data; 581 char *data;
543 char *template; 582 char *template;
583 if (GNUNET_YES == full)
584 GNUNET_asprintf (&gfn, "perf_%s_full_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
585 else
586 GNUNET_asprintf (&gfn, "perf_%s_update_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
544 587
545 GNUNET_asprintf (&gfn, "perf_%s_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
546 f = GNUNET_DISK_file_open (gfn, 588 f = GNUNET_DISK_file_open (gfn,
547 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 589 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
548 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 590 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
@@ -556,13 +598,22 @@ write_gnuplot_script (char * data_fn)
556 /* Write header */ 598 /* Write header */
557 switch (ph.ats_mode) { 599 switch (ph.ats_mode) {
558 case MODE_PROPORTIONAL: 600 case MODE_PROPORTIONAL:
559 template = GNUPLOT_PROP_TEMPLATE; 601 if (GNUNET_YES == full)
602 template = GNUPLOT_PROP_TEMPLATE;
603 else
604 template = GNUPLOT_PROP_UPDATE_TEMPLATE;
560 break; 605 break;
561 case MODE_MLP: 606 case MODE_MLP:
562 template = GNUPLOT_MLP_TEMPLATE; 607 if (GNUNET_YES == full)
608 template = GNUPLOT_MLP_TEMPLATE;
609 else
610 template = GNUPLOT_MLP_UPDATE_TEMPLATE;
563 break; 611 break;
564 case MODE_RIL: 612 case MODE_RIL:
565 template = GNUPLOT_RIL_TEMPLATE; 613 if (GNUNET_YES == full)
614 template = GNUPLOT_RIL_TEMPLATE;
615 else
616 template = GNUPLOT_RIL_UPDATE_TEMPLATE;
566 break; 617 break;
567 default: 618 default:
568 break; 619 break;
@@ -611,8 +662,10 @@ write_gnuplot_script (char * data_fn)
611static void 662static void
612evaluate () 663evaluate ()
613{ 664{
614 struct GNUNET_DISK_FileHandle *f; 665 struct GNUNET_DISK_FileHandle *f_full;
615 char * data_fn; 666 struct GNUNET_DISK_FileHandle *f_update;
667 char * data_fn_full;
668 char * data_fn_update;
616 char * data; 669 char * data;
617 struct Result *cur; 670 struct Result *cur;
618 struct Result *next; 671 struct Result *next;
@@ -623,30 +676,52 @@ evaluate ()
623 676
624 if (ph.create_plot) 677 if (ph.create_plot)
625 { 678 {
626 GNUNET_asprintf (&data_fn, "perf_%s_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); 679 GNUNET_asprintf (&data_fn_full, "perf_%s_full_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
627 f = GNUNET_DISK_file_open (data_fn, 680 f_full = GNUNET_DISK_file_open (data_fn_full,
628 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 681 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
629 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 682 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
630 if (NULL == f) 683 if (NULL == f_full)
631 { 684 {
632 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn); 685 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn_full);
633 return; 686 return;
634 } 687 }
635 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; 688 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
636 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 689 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
637 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn); 690 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_full);
638 write_gnuplot_script (data_fn); 691 write_gnuplot_script (data_fn_full, GNUNET_YES);
692
693 }
694 if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates))
695 {
696 GNUNET_asprintf (&data_fn_update, "perf_%s_update_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
697 f_update = GNUNET_DISK_file_open (data_fn_update,
698 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
699 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
700 if (NULL == f_update)
701 {
702 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn_update);
703 return;
704 }
705 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
706 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data)))
707 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_update);
708 write_gnuplot_script (data_fn_update, GNUNET_NO);
639 } 709 }
640 710
641 next = ph.head; 711 next = ph.head;
642 while (NULL != (cur = next)) 712 while (NULL != (cur = next))
643 { 713 {
644 next = cur->next; 714 next = cur->next;
715 str_d_total = NULL;
716 str_d_setup = NULL;
717 str_d_lp = NULL;
718 str_d_mlp = NULL;
645 719
646 /* Print log */ 720 /* Print log */
647 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) 721 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us)
648 { 722 {
649 fprintf (stderr, "Total time to solve for %u peers %u addresses: %llu us\n", 723 fprintf (stderr, "Total time to solve %s for %u peers %u addresses: %llu us\n",
724 (GNUNET_YES == cur->update) ? "updated" : "full",
650 cur->peers, cur->addresses, (unsigned long long )cur->d_total.rel_value_us); 725 cur->peers, cur->addresses, (unsigned long long )cur->d_total.rel_value_us);
651 GNUNET_asprintf(&str_d_total, "%llu", (unsigned long long )cur->d_total.rel_value_us); 726 GNUNET_asprintf(&str_d_total, "%llu", (unsigned long long )cur->d_total.rel_value_us);
652 } 727 }
@@ -654,7 +729,8 @@ evaluate ()
654 GNUNET_asprintf(&str_d_total, "-1"); 729 GNUNET_asprintf(&str_d_total, "-1");
655 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) 730 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us)
656 { 731 {
657 fprintf (stderr, "Total time to setup %u peers %u addresses: %llu us\n", 732 fprintf (stderr, "Total time to setup %s %u peers %u addresses: %llu us\n",
733 (GNUNET_YES == cur->update) ? "updated" : "full",
658 cur->peers, cur->addresses, (unsigned long long )cur->d_setup.rel_value_us); 734 cur->peers, cur->addresses, (unsigned long long )cur->d_setup.rel_value_us);
659 GNUNET_asprintf(&str_d_setup, "%llu", (unsigned long long )cur->d_setup.rel_value_us); 735 GNUNET_asprintf(&str_d_setup, "%llu", (unsigned long long )cur->d_setup.rel_value_us);
660 } 736 }
@@ -662,7 +738,8 @@ evaluate ()
662 GNUNET_asprintf(&str_d_setup, "-1"); 738 GNUNET_asprintf(&str_d_setup, "-1");
663 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) 739 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us)
664 { 740 {
665 fprintf (stderr, "Total time to solve LP for %u peers %u addresses: %llu us\n", 741 fprintf (stderr, "Total time to solve %s LP for %u peers %u addresses: %llu us\n",
742 (GNUNET_YES == cur->update) ? "updated" : "full",
666 cur->peers, cur->addresses, (unsigned long long )cur->d_lp.rel_value_us); 743 cur->peers, cur->addresses, (unsigned long long )cur->d_lp.rel_value_us);
667 GNUNET_asprintf(&str_d_lp, "%llu", (unsigned long long )cur->d_lp.rel_value_us); 744 GNUNET_asprintf(&str_d_lp, "%llu", (unsigned long long )cur->d_lp.rel_value_us);
668 } 745 }
@@ -670,7 +747,8 @@ evaluate ()
670 GNUNET_asprintf(&str_d_lp, "-1"); 747 GNUNET_asprintf(&str_d_lp, "-1");
671 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) 748 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us)
672 { 749 {
673 fprintf (stderr, "Total time to solve MLP for %u peers %u addresses: %llu us\n", 750 fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n",
751 (GNUNET_YES == cur->update) ? "updated" : "full",
674 cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us); 752 cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us);
675 GNUNET_asprintf(&str_d_mlp, "%llu", (unsigned long long )cur->d_mlp.rel_value_us); 753 GNUNET_asprintf(&str_d_mlp, "%llu", (unsigned long long )cur->d_mlp.rel_value_us);
676 } 754 }
@@ -686,24 +764,38 @@ evaluate ()
686 str_d_setup, 764 str_d_setup,
687 str_d_lp, 765 str_d_lp,
688 str_d_mlp); 766 str_d_mlp);
689 767 if (cur->update == GNUNET_NO)
690 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 768 {
691 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn); 769 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
692 GNUNET_free (str_d_total); 770 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_full);
693 GNUNET_free (str_d_setup); 771 }
694 GNUNET_free (str_d_lp); 772 if (cur->update == GNUNET_YES)
695 GNUNET_free (str_d_mlp); 773 {
774 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data)))
775 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_update);
776 }
696 GNUNET_free (data); 777 GNUNET_free (data);
697 } 778 }
779 GNUNET_free_non_null (str_d_total);
780 GNUNET_free_non_null (str_d_setup);
781 GNUNET_free_non_null (str_d_lp);
782 GNUNET_free_non_null (str_d_mlp);
783
698 GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur); 784 GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur);
699 GNUNET_free (cur); 785 GNUNET_free (cur);
700 } 786 }
701 787
702 if (GNUNET_YES == ph.create_plot) 788 if (GNUNET_YES == ph.create_plot)
703 { 789 {
704 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 790 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_full))
705 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", data_fn); 791 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", data_fn_full);
706 GNUNET_free (data_fn); 792 GNUNET_free (data_fn_full);
793 }
794 if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates))
795 {
796 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_update))
797 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", data_fn_update);
798 GNUNET_free (data_fn_update);
707 } 799 }
708} 800}
709 801
@@ -726,12 +818,13 @@ perf_run ()
726 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 818 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
727 "Added %u peers\n", cp); 819 "Added %u peers\n", cp);
728 820
729 /* Set initial bulk start to not solve */
730 ph.env.sf.s_bulk_start (ph.solver);
731 ph.bulk_running = GNUNET_YES;
732
733 for (cp = 0; cp < count_p; cp++) 821 for (cp = 0; cp < count_p; cp++)
734 { 822 {
823 if (GNUNET_NO == ph.bulk_running)
824 {
825 ph.bulk_running = GNUNET_YES;
826 ph.env.sf.s_bulk_start (ph.solver);
827 }
735 ph.current_p = cp + 1; 828 ph.current_p = cp + 1;
736 for (ca = 0; ca < count_a; ca++) 829 for (ca = 0; ca < count_a; ca++)
737 { 830 {
@@ -751,8 +844,8 @@ perf_run ()
751 /* Disable bulk to solve the problem */ 844 /* Disable bulk to solve the problem */
752 if (GNUNET_YES == ph.bulk_running) 845 if (GNUNET_YES == ph.bulk_running)
753 { 846 {
754 ph.bulk_running = GNUNET_NO;
755 ph.expecting_solution = GNUNET_YES; 847 ph.expecting_solution = GNUNET_YES;
848 ph.bulk_running = GNUNET_NO;
756 ph.env.sf.s_bulk_stop (ph.solver); 849 ph.env.sf.s_bulk_stop (ph.solver);
757 } 850 }
758 else 851 else
@@ -761,27 +854,31 @@ perf_run ()
761 } 854 }
762 855
763 /* Problem is solved by the solver here due to unlocking */ 856 /* Problem is solved by the solver here due to unlocking */
764
765 ph.expecting_solution = GNUNET_NO; 857 ph.expecting_solution = GNUNET_NO;
766 /* Disable bulk to solve the problem */ 858
767 if (GNUNET_NO == ph.bulk_running) 859 /* Update the problem */
768 { 860 if ((0 < ph.opt_update_percent) && (GNUNET_YES == ph.measure_updates))
769 ph.env.sf.s_bulk_start (ph.solver);
770 ph.bulk_running = GNUNET_YES;
771 }
772#if 0
773 if ((0 < ph.opt_update_quantity) || (0 < ph.opt_update_percent))
774 { 861 {
775 /* Update */ 862 /* Update */
776 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 863 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
777 "Updating problem with %u peers and %u addresses\n", cp + 1, ca); 864 "Updating problem with %u peers and %u addresses\n", cp + 1, ca);
778 //ph.env.sf.s_bulk_start (ph.solver); 865
779 //update_addresses (cp + 1, ca, ph.opt_update_quantity); 866 ph.expecting_solution = GNUNET_YES;
780 //ph.env.sf.s_bulk_stop (ph.solver); 867 if (GNUNET_NO == ph.bulk_running)
868 {
869 ph.bulk_running = GNUNET_YES;
870 ph.env.sf.s_bulk_start (ph.solver);
871 }
872 perf_update_all_addresses (cp + 1, ca, ph.opt_update_percent);
873 ph.bulk_running = GNUNET_NO;
874 ph.env.sf.s_bulk_stop (ph.solver);
875 /* Problem is solved by the solver here due to unlocking */
876 ph.expecting_solution = GNUNET_NO;
781 } 877 }
782#endif 878 GNUNET_assert (GNUNET_NO == ph.bulk_running);
783 } 879 }
784 } 880 }
881
785 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 882 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
786 "Done, cleaning up addresses\n"); 883 "Done, cleaning up addresses\n");
787 if (GNUNET_NO == ph.bulk_running) 884 if (GNUNET_NO == ph.bulk_running)
@@ -877,14 +974,6 @@ run (void *cls, char * const *args, const char *cfgfile,
877 if (0 == ph.N_address) 974 if (0 == ph.N_address)
878 ph.N_address = DEFAULT_ADDRESSES; 975 ph.N_address = DEFAULT_ADDRESSES;
879 976
880 if (ph.opt_update_quantity > ph.N_address)
881 {
882 fprintf (stderr,
883 _("Trying to update more addresses than we have per peer! (%u vs %u)"),
884 ph.opt_update_quantity, ph.N_address);
885 exit (1);
886 }
887
888 if (ph.N_peers_start != ph.N_peers_end) 977 if (ph.N_peers_start != ph.N_peers_end)
889 fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses\n", 978 fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses\n",
890 ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); 979 ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address);
@@ -892,6 +981,9 @@ run (void *cls, char * const *args, const char *cfgfile,
892 fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses\n", 981 fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses\n",
893 ph.ats_string, ph.N_peers_end, ph.N_address); 982 ph.ats_string, ph.N_peers_end, ph.N_address);
894 983
984 if (0 == ph.opt_update_percent)
985 ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE;
986
895 /* Load quotas */ 987 /* Load quotas */
896 if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, 988 if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg,
897 quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount)) 989 quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount))
@@ -950,13 +1042,13 @@ int
950main (int argc, char *argv[]) 1042main (int argc, char *argv[])
951{ 1043{
952 /* extract command line arguments */ 1044 /* extract command line arguments */
953 ph.opt_update_quantity = 0;
954 ph.opt_update_percent = 0; 1045 ph.opt_update_percent = 0;
955 ph.N_peers_start = 0; 1046 ph.N_peers_start = 0;
956 ph.N_peers_end = 0; 1047 ph.N_peers_end = 0;
957 ph.N_address = 0; 1048 ph.N_address = 0;
958 ph.ats_string = NULL; 1049 ph.ats_string = NULL;
959 ph.create_plot = GNUNET_NO; 1050 ph.create_plot = GNUNET_NO;
1051 ph.measure_updates = GNUNET_NO;
960 1052
961 static struct GNUNET_GETOPT_CommandLineOption options[] = { 1053 static struct GNUNET_GETOPT_CommandLineOption options[] = {
962 { 'a', "addresses", NULL, 1054 { 'a', "addresses", NULL,
@@ -971,12 +1063,12 @@ main (int argc, char *argv[])
971 { 'p', "percentage", NULL, 1063 { 'p', "percentage", NULL,
972 gettext_noop ("update a fix percentage of addresses"), 1064 gettext_noop ("update a fix percentage of addresses"),
973 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, 1065 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent },
974 { 'q', "quantity", NULL,
975 gettext_noop ("update a fix quantity of addresses"),
976 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_quantity },
977 { 'g', "gnuplot", NULL, 1066 { 'g', "gnuplot", NULL,
978 gettext_noop ("create GNUplot file"), 1067 gettext_noop ("create GNUplot file"),
979 0, &GNUNET_GETOPT_set_one, &ph.create_plot}, 1068 0, &GNUNET_GETOPT_set_one, &ph.create_plot},
1069 { 'u', "update", NULL,
1070 gettext_noop ("measure updates"),
1071 0, &GNUNET_GETOPT_set_one, &ph.measure_updates},
980 GNUNET_GETOPT_OPTION_END 1072 GNUNET_GETOPT_OPTION_END
981 }; 1073 };
982 1074
diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h
index 51a79db68..ed081f39a 100644
--- a/src/include/gnunet_ats_plugin.h
+++ b/src/include/gnunet_ats_plugin.h
@@ -326,8 +326,8 @@ enum GAS_Solver_Status
326enum GAS_Solver_Additional_Information 326enum GAS_Solver_Additional_Information
327{ 327{
328 GAS_INFO_NONE, 328 GAS_INFO_NONE,
329 GAS_INFO_MLP_FULL, 329 GAS_INFO_FULL,
330 GAS_INFO_MLP_UPDATED, 330 GAS_INFO_UPDATED,
331 GAS_INFO_PROP_ALL, 331 GAS_INFO_PROP_ALL,
332 GAS_INFO_PROP_SINGLE 332 GAS_INFO_PROP_SINGLE
333}; 333};