aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats_solver.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-10-30 16:09:35 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-10-30 16:09:35 +0000
commitfbe5b7ab37b85a80a96481af0608cd87ff70f61d (patch)
tree0d75455def8792ee7cfc17aaa10f71238ee1b94e /src/ats/perf_ats_solver.c
parent391cab6592e846c432644a55678b5b805cd39b7a (diff)
downloadgnunet-fbe5b7ab37b85a80a96481af0608cd87ff70f61d.tar.gz
gnunet-fbe5b7ab37b85a80a96481af0608cd87ff70f61d.zip
improved benchmarking
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r--src/ats/perf_ats_solver.c241
1 files changed, 199 insertions, 42 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index f2762baba..631594b06 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -42,70 +42,108 @@
42 */ 42 */
43struct PerfHandle 43struct PerfHandle
44{ 44{
45 /**
46 * Performance peers
47 */
45 struct PerfPeer *peers; 48 struct PerfPeer *peers;
46 49
47 /** 50 /**
48 * #peers to start benchmarking with 51 * Solver handle
49 */ 52 */
50 int N_peers_start; 53 void *solver;
51 54
52 /** 55 /**
53 * #peers to end benchmarking with 56 * Statistics stat;
54 */ 57 */
55 int N_peers_end; 58 struct GNUNET_STATISTICS_Handle *stat;
56 59
57 /** 60 /**
58 * #addresses to benchmarking with 61 * A multihashmap to store all addresses
59 */ 62 */
60 int N_address; 63 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
61 64
62 int opt_numeric; 65 /**
63 int opt_dump; 66 * Solver functions
64 int opt_update_percent; 67 * */
65 int opt_update_quantity; 68 struct GNUNET_ATS_PluginEnvironment env;
69
70 struct Result *head;
71
72 struct Result *tail;
73
74 struct Result *current_result;
75
76 int current_p;
77 int current_a;
66 78
67 /** 79 /**
68 * Is a bulk operation running? 80 * Solver description as string
69 */ 81 */
70 int bulk_running;
71
72 char *ats_string; 82 char *ats_string;
73 83
74 /** 84 /**
75 * 85 * Configured ATS solver
76 */ 86 */
77 struct GNUNET_STATISTICS_Handle *stat; 87 int ats_mode;
78 88
79 /** 89 /**
80 * A multihashmap to store all addresses 90 * #peers to start benchmarking with
81 */ 91 */
82 struct GNUNET_CONTAINER_MultiPeerMap *addresses; 92 int N_peers_start;
83 93
94 /**
95 * #peers to end benchmarking with
96 */
97 int N_peers_end;
84 98
85 /** 99 /**
86 * Configured ATS solver 100 * #addresses to benchmarking with
87 */ 101 */
88 int ats_mode; 102 int N_address;
89 103
90 /** 104 /**
91 * Solver handle 105 * Percentage of peers to update
92 */ 106 */
93 void *solver; 107 int opt_update_percent;
94 108
95 /** 109 /**
96 * Address suggestion requests DLL head 110 * Number of peers to update
97 */ 111 */
98 struct GAS_Addresses_Suggestion_Requests *r_head; 112 int opt_update_quantity;
99 113
100 /** 114 /**
101 * Address suggestion requests DLL tail 115 * Is a bulk operation running?
102 */ 116 */
103 struct GAS_Addresses_Suggestion_Requests *r_tail; 117 int bulk_running;
104 118
105 /* Solver functions */ 119 /**
106 struct GNUNET_ATS_PluginEnvironment env; 120 * Is a bulk operation running?
121 */
122 int expecting_solution;
123};
107 124
108 char *plugin; 125struct Result
126{
127 struct Result *prev;
128 struct Result *next;
129
130 int peers;
131 int addresses;
132
133 struct GNUNET_TIME_Relative d_setup;
134 struct GNUNET_TIME_Relative d_lp;
135 struct GNUNET_TIME_Relative d_mlp;
136 struct GNUNET_TIME_Relative d_total;
137
138 struct GNUNET_TIME_Absolute s_setup;
139 struct GNUNET_TIME_Absolute s_lp;
140 struct GNUNET_TIME_Absolute s_mlp;
141 struct GNUNET_TIME_Absolute s_total;
142
143 struct GNUNET_TIME_Absolute e_setup;
144 struct GNUNET_TIME_Absolute e_lp;
145 struct GNUNET_TIME_Absolute e_mlp;
146 struct GNUNET_TIME_Absolute e_total;
109}; 147};
110 148
111struct PerfPeer 149struct PerfPeer
@@ -311,49 +349,135 @@ perf_create_address (int cp, int ca)
311} 349}
312 350
313static void 351static void
314solver_info_cb (void *cls, 352solver_info_cb (void *cls, enum GAS_Solver_Operation op,
315 enum GAS_Solver_Operation op, enum GAS_Solver_Status stat) 353 enum GAS_Solver_Status stat)
316{ 354{
317 switch (op) { 355
356 struct Result *tmp;
357 switch (op)
358 {
359
318 case GAS_OP_SOLVE_START: 360 case GAS_OP_SOLVE_START:
319 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 361 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
320 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_START", 362 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_START",
321 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 363 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
364 if (GNUNET_NO == ph.expecting_solution)
365 {
366 GNUNET_break(0);
367 return;
368 }
369 if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result))
370 {
371 /* Create new result */
372 tmp = GNUNET_malloc (sizeof (struct Result));
373 ph.current_result = tmp;
374 GNUNET_CONTAINER_DLL_insert_tail(ph.head, ph.tail, tmp);
375 ph.current_result->addresses = ph.current_a;
376 ph.current_result->peers = ph.current_p;
377 ph.current_result->s_total = GNUNET_TIME_absolute_get ();
378 ph.current_result->d_total = GNUNET_TIME_relative_get_forever_ ();
379 ph.current_result->d_setup = GNUNET_TIME_relative_get_forever_ ();
380 ph.current_result->d_lp = GNUNET_TIME_relative_get_forever_ ();
381 ph.current_result->d_mlp = GNUNET_TIME_relative_get_forever_ ();
382 }
383
322 break; 384 break;
385
323 case GAS_OP_SOLVE_STOP: 386 case GAS_OP_SOLVE_STOP:
324 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 387 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
325 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP", 388 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
326 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 389 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
390
391 if (NULL != ph.current_result)
392 {
393 /* Finalize result */
394 ph.current_result->e_total = GNUNET_TIME_absolute_get ();
395 ph.current_result->d_total = GNUNET_TIME_absolute_get_difference (
396 ph.current_result->s_total, ph.current_result->e_total);
397 }
398 ph.current_result = NULL;
327 break; 399 break;
400
328 case GAS_OP_SOLVE_SETUP_START: 401 case GAS_OP_SOLVE_SETUP_START:
329 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 402 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
330 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START", 403 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
331 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 404 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
405 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
406 {
407 GNUNET_break(0);
408 return;
409 }
410 ph.current_result->s_setup = GNUNET_TIME_absolute_get ();
332 break; 411 break;
412
333 case GAS_OP_SOLVE_SETUP_STOP: 413 case GAS_OP_SOLVE_SETUP_STOP:
334 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 414 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
335 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP", 415 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
336 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 416 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
417
418 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
419 {
420 GNUNET_break(0);
421 return;
422 }
423 ph.current_result->e_setup = GNUNET_TIME_absolute_get ();
424 ph.current_result->d_setup = GNUNET_TIME_absolute_get_difference (
425 ph.current_result->s_setup, ph.current_result->e_setup);
337 break; 426 break;
427
338 case GAS_OP_SOLVE_LP_START: 428 case GAS_OP_SOLVE_LP_START:
339 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 429 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
340 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START", 430 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
341 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 431 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
432
433 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
434 {
435 GNUNET_break(0);
436 return;
437 }
438 ph.current_result->s_lp = GNUNET_TIME_absolute_get ();
342 break; 439 break;
440
343 case GAS_OP_SOLVE_LP_STOP: 441 case GAS_OP_SOLVE_LP_STOP:
344 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 442 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
345 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP", 443 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
346 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 444 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
445 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
446 {
447 GNUNET_break(0);
448 return;
449 }
450 ph.current_result->e_lp = GNUNET_TIME_absolute_get ();
451 ph.current_result->d_lp = GNUNET_TIME_absolute_get_difference (
452 ph.current_result->s_lp, ph.current_result->e_lp);
453 break;
454
347 break; 455 break;
456
348 case GAS_OP_SOLVE_MLP_START: 457 case GAS_OP_SOLVE_MLP_START:
349 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 458 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
350 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START", 459 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
351 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 460 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
461 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
462 {
463 GNUNET_break(0);
464 return;
465 }
466 ph.current_result->s_mlp = GNUNET_TIME_absolute_get ();
352 break; 467 break;
468
353 case GAS_OP_SOLVE_MLP_STOP: 469 case GAS_OP_SOLVE_MLP_STOP:
354 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 470 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
355 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP", 471 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
356 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 472 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
473 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
474 {
475 GNUNET_break(0);
476 return;
477 }
478 ph.current_result->e_mlp = GNUNET_TIME_absolute_get ();
479 ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference (
480 ph.current_result->s_mlp, ph.current_result->e_mlp);
357 break; 481 break;
358 default: 482 default:
359 break; 483 break;
@@ -361,6 +485,43 @@ solver_info_cb (void *cls,
361} 485}
362 486
363static void 487static void
488evaluate ()
489{
490 struct Result *cur;
491 struct Result *next;
492
493 next = ph.head;
494 while (NULL != (cur = next))
495 {
496 next = cur->next;
497
498 if (GNUNET_TIME_relative_get_forever_().rel_value_us != cur->d_total.rel_value_us)
499 {
500 fprintf (stderr, "Total time to solve for %u peers %u addresses: %llu us\n",
501 cur->peers, cur->addresses, (unsigned long long )cur->d_total.rel_value_us);
502 }
503 if (GNUNET_TIME_relative_get_forever_().rel_value_us != cur->d_setup.rel_value_us)
504 {
505 fprintf (stderr, "Total time to setup %u peers %u addresses: %llu us\n",
506 cur->peers, cur->addresses, (unsigned long long )cur->d_setup.rel_value_us);
507 }
508 if (GNUNET_TIME_relative_get_forever_().rel_value_us != cur->d_lp.rel_value_us)
509 {
510 fprintf (stderr, "Total time to solve LP for %u peers %u addresses: %llu us\n",
511 cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us);
512 }
513 if (GNUNET_TIME_relative_get_forever_().rel_value_us != cur->d_mlp.rel_value_us)
514 {
515 fprintf (stderr, "Total time to solve MLP for %u peers %u addresses: %llu us\n",
516 cur->peers, cur->addresses, (unsigned long long )cur->d_lp.rel_value_us);
517 }
518
519 GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur);
520 GNUNET_free (cur);
521 }
522}
523
524static void
364perf_run () 525perf_run ()
365{ 526{
366 struct ATS_Address *cur; 527 struct ATS_Address *cur;
@@ -370,9 +531,7 @@ perf_run ()
370 int count_p = ph.N_peers_end; 531 int count_p = ph.N_peers_end;
371 int count_a = ph.N_address; 532 int count_a = ph.N_address;
372 struct ATS_Address * cur_addr; 533 struct ATS_Address * cur_addr;
373 struct GNUNET_TIME_Absolute start; 534
374 struct GNUNET_TIME_Absolute end;
375 struct GNUNET_TIME_Relative delta;
376 535
377 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); 536 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
378 537
@@ -404,8 +563,10 @@ perf_run ()
404 /* Disable bulk to solve the problem */ 563 /* Disable bulk to solve the problem */
405 if (GNUNET_YES == ph.bulk_running) 564 if (GNUNET_YES == ph.bulk_running)
406 { 565 {
407 start = GNUNET_TIME_absolute_get();
408 ph.bulk_running = GNUNET_NO; 566 ph.bulk_running = GNUNET_NO;
567 ph.expecting_solution = GNUNET_YES;
568 ph.current_p = cp + 1;
569 ph.current_a = ca;
409 ph.env.sf.s_bulk_stop (ph.solver); 570 ph.env.sf.s_bulk_stop (ph.solver);
410 } 571 }
411 else 572 else
@@ -415,15 +576,10 @@ perf_run ()
415 576
416 /* Problem is solved by the solver here due to unlocking */ 577 /* Problem is solved by the solver here due to unlocking */
417 578
579 ph.expecting_solution = GNUNET_NO;
418 /* Disable bulk to solve the problem */ 580 /* Disable bulk to solve the problem */
419 if (GNUNET_NO == ph.bulk_running) 581 if (GNUNET_NO == ph.bulk_running)
420 { 582 {
421
422 end = GNUNET_TIME_absolute_get();
423 delta = GNUNET_TIME_absolute_get_difference(start, end);
424 fprintf (stderr, "Solver took %llu us to solve problem with %u peers and %u addresses per peer\n",
425 (unsigned long long) delta.rel_value_us,
426 cp + 1, ca);
427 ph.env.sf.s_bulk_start (ph.solver); 583 ph.env.sf.s_bulk_start (ph.solver);
428 ph.bulk_running = GNUNET_YES; 584 ph.bulk_running = GNUNET_YES;
429 } 585 }
@@ -463,6 +619,8 @@ perf_run ()
463 619
464 } 620 }
465 GNUNET_free(ph.peers); 621 GNUNET_free(ph.peers);
622
623 evaluate ();
466} 624}
467 625
468 626
@@ -606,7 +764,6 @@ int
606main (int argc, char *argv[]) 764main (int argc, char *argv[])
607{ 765{
608 /* extract command line arguments */ 766 /* extract command line arguments */
609 ph.opt_dump = GNUNET_NO;
610 ph.opt_update_quantity = 0; 767 ph.opt_update_quantity = 0;
611 ph.opt_update_percent = 0; 768 ph.opt_update_percent = 0;
612 ph.N_peers_start = 0; 769 ph.N_peers_start = 0;