aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-10-25 11:57:32 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-10-25 11:57:32 +0000
commit9ac6dc6bfcd74b44d7096e2f99d16f47a35fe75a (patch)
tree636ba0f47c672dec2009f6c39e81f24297bc720a
parent5e65f74556781390240c444e1bf24f9b0b777ed2 (diff)
downloadgnunet-9ac6dc6bfcd74b44d7096e2f99d16f47a35fe75a.tar.gz
gnunet-9ac6dc6bfcd74b44d7096e2f99d16f47a35fe75a.zip
regex profiler fixes
-rw-r--r--src/mesh/gnunet-regex-profiler.c118
-rw-r--r--src/mesh/regex_profiler_test.conf5
2 files changed, 90 insertions, 33 deletions
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c
index 90b25e1c9..e6178eac6 100644
--- a/src/mesh/gnunet-regex-profiler.c
+++ b/src/mesh/gnunet-regex-profiler.c
@@ -159,6 +159,11 @@ struct RegexPeer
159 * Testbed operation handle for the statistics service. 159 * Testbed operation handle for the statistics service.
160 */ 160 */
161 struct GNUNET_TESTBED_Operation *stats_op_handle; 161 struct GNUNET_TESTBED_Operation *stats_op_handle;
162
163 /**
164 * The starting time of a profiling step.
165 */
166 struct GNUNET_TIME_Absolute prof_start_time;
162}; 167};
163 168
164/** 169/**
@@ -248,6 +253,11 @@ static unsigned int num_peers;
248static unsigned int num_hosts; 253static unsigned int num_hosts;
249 254
250/** 255/**
256 * Factor of number of links. num_links = num_peers * linking_factor.
257 */
258static unsigned int linking_factor;
259
260/**
251 * Number of random links to be established between peers 261 * Number of random links to be established between peers
252 */ 262 */
253static unsigned int num_links; 263static unsigned int num_links;
@@ -329,6 +339,45 @@ static struct GNUNET_DISK_FileHandle *data_file;
329static char *data_filename; 339static char *data_filename;
330 340
331 341
342/******************************************************************************/
343/****************************** DECLARATIONS ********************************/
344/******************************************************************************/
345
346
347/**
348 * Method called whenever a peer has connected to the tunnel.
349 *
350 * @param cls closure
351 * @param peer_id peer identity the tunnel was created to, NULL on timeout
352 * @param atsi performance data for the connection
353 *
354 */
355void
356mesh_peer_connect_handler (void *cls,
357 const struct GNUNET_PeerIdentity* peer_id,
358 const struct GNUNET_ATS_Information * atsi);
359
360
361/**
362 * Method called whenever a peer has disconnected from the tunnel.
363 * Implementations of this callback must NOT call
364 * GNUNET_MESH_tunnel_destroy immediately, but instead schedule those
365 * to run in some other task later. However, calling
366 * "GNUNET_MESH_notify_transmit_ready_cancel" is allowed.
367 *
368 * @param cls closure
369 * @param peer_id peer identity the tunnel stopped working with
370 */
371void
372mesh_peer_disconnect_handler (void *cls,
373 const struct GNUNET_PeerIdentity * peer_id);
374
375
376/******************************************************************************/
377/******************************** SHUTDOWN **********************************/
378/******************************************************************************/
379
380
332/** 381/**
333 * Shutdown nicely 382 * Shutdown nicely
334 * 383 *
@@ -497,6 +546,9 @@ stats_cb (void *cls,
497 return; 546 return;
498 } 547 }
499 548
549 GNUNET_TESTBED_operation_done (peer->stats_op_handle);
550 peer->stats_op_handle = NULL;
551
500 if (++peer_cnt == num_search_strings) 552 if (++peer_cnt == num_search_strings)
501 { 553 {
502 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 554 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
@@ -525,11 +577,21 @@ stats_connect_cb (void *cls,
525 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 577 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
526 "Failed to connect to statistics service on peer %u: %s\n", 578 "Failed to connect to statistics service on peer %u: %s\n",
527 peer->id, emsg); 579 peer->id, emsg);
528 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
529 return; 580 return;
530 } 581 }
531 582
532 peer->stats_handle = ca_result; 583 peer->stats_handle = ca_result;
584
585 peer->mesh_tunnel_handle = GNUNET_MESH_tunnel_create (peer->mesh_handle,
586 NULL,
587 &mesh_peer_connect_handler,
588 &mesh_peer_disconnect_handler,
589 peer);
590
591 peer->prof_start_time = GNUNET_TIME_absolute_get ();
592
593 GNUNET_MESH_peer_request_connect_by_string (peer->mesh_tunnel_handle,
594 peer->search_str);
533} 595}
534 596
535 597
@@ -628,7 +690,7 @@ mesh_peer_connect_handler (void *cls,
628 } 690 }
629 else 691 else
630 { 692 {
631 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); 693 prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time);
632 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 694 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
633 "String %s successfully matched on peer %u after %s (%i/%i)\n", 695 "String %s successfully matched on peer %u after %s (%i/%i)\n",
634 peer->search_str, peer->id, GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), 696 peer->search_str, peer->id, GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
@@ -683,6 +745,8 @@ mesh_peer_connect_handler (void *cls,
683 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 745 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
684 "All strings successfully matched in %s\n", 746 "All strings successfully matched in %s\n",
685 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); 747 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
748 printf ("All strings successfully matched. Shutting down.\n");
749 fflush (stdout);
686 750
687 if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task) 751 if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
688 GNUNET_SCHEDULER_cancel (search_timeout_task); 752 GNUNET_SCHEDULER_cancel (search_timeout_task);
@@ -732,18 +796,18 @@ do_connect_by_string (void *cls,
732 "Searching for string \"%s\" on peer %d with file %s\n", 796 "Searching for string \"%s\" on peer %d with file %s\n",
733 peer->search_str, (search_cnt % num_peers), peer->policy_file); 797 peer->search_str, (search_cnt % num_peers), peer->policy_file);
734 798
735 peer->mesh_tunnel_handle = GNUNET_MESH_tunnel_create (peer->mesh_handle, 799 /* First connect to stats service, then try connecting by string in stats_connect_cb */
736 NULL, 800 peer->stats_op_handle =
737 &mesh_peer_connect_handler, 801 GNUNET_TESTBED_service_connect (NULL,
738 &mesh_peer_disconnect_handler, 802 peers->peer_handle,
739 peer); 803 "statistics",
740 804 &stats_connect_cb,
741 GNUNET_MESH_peer_request_connect_by_string (peer->mesh_tunnel_handle, 805 peer,
742 peer->search_str); 806 &stats_ca,
807 &stats_da,
808 peer);
743 } 809 }
744 810
745 prof_start_time = GNUNET_TIME_absolute_get ();
746
747 search_timeout_task = GNUNET_SCHEDULER_add_delayed (search_timeout, 811 search_timeout_task = GNUNET_SCHEDULER_add_delayed (search_timeout,
748 &do_connect_by_string_timeout, NULL); 812 &do_connect_by_string_timeout, NULL);
749} 813}
@@ -827,7 +891,7 @@ mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
827 891
828 if (++connected_mesh_handles == num_peers) 892 if (++connected_mesh_handles == num_peers)
829 { 893 {
830 printf ("Waiting %s before starting to search.\n", 894 printf ("\nWaiting %s before starting to search.\n",
831 GNUNET_STRINGS_relative_time_to_string (search_delay, GNUNET_YES)); 895 GNUNET_STRINGS_relative_time_to_string (search_delay, GNUNET_YES));
832 fflush (stdout); 896 fflush (stdout);
833 897
@@ -938,13 +1002,14 @@ peer_churn_cb (void *cls, const char *emsg)
938 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); 1002 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
939 result = GNUNET_OK; 1003 result = GNUNET_OK;
940 1004
941 if (0 == num_links)
942 num_links = num_peers * 5;
943
944 peer_handles = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * num_peers); 1005 peer_handles = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * num_peers);
945 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) 1006 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
946 peer_handles[peer_cnt] = peers[peer_cnt].peer_handle; 1007 peer_handles[peer_cnt] = peers[peer_cnt].peer_handle;
947 1008
1009 if (0 == linking_factor)
1010 linking_factor = 1;
1011 num_links = linking_factor * num_peers;
1012
948 state = STATE_PEERS_LINKING; 1013 state = STATE_PEERS_LINKING;
949 /* Do overlay connect */ 1014 /* Do overlay connect */
950 prof_start_time = GNUNET_TIME_absolute_get (); 1015 prof_start_time = GNUNET_TIME_absolute_get ();
@@ -1155,7 +1220,7 @@ controller_event_cb (void *cls,
1155 printf ("F"); 1220 printf ("F");
1156 fflush (stdout); 1221 fflush (stdout);
1157 retry_links++; 1222 retry_links++;
1158 1223
1159 if (++cont_fails > num_cont_fails) 1224 if (++cont_fails > num_cont_fails)
1160 { 1225 {
1161 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1226 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1181,7 +1246,6 @@ controller_event_cb (void *cls,
1181 } 1246 }
1182 if (++established_links == num_links) 1247 if (++established_links == num_links)
1183 { 1248 {
1184 printf ("\n");
1185 fflush (stdout); 1249 fflush (stdout);
1186 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); 1250 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
1187 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1251 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1219,16 +1283,6 @@ controller_event_cb (void *cls,
1219 &mesh_ca, 1283 &mesh_ca,
1220 &mesh_da, 1284 &mesh_da,
1221 &peers[peer_cnt]); 1285 &peers[peer_cnt]);
1222
1223 peers[peer_cnt].stats_op_handle =
1224 GNUNET_TESTBED_service_connect (NULL,
1225 peers[peer_cnt].peer_handle,
1226 "statistics",
1227 &stats_connect_cb,
1228 &peers[peer_cnt],
1229 &stats_ca,
1230 &stats_da,
1231 &peers[peer_cnt]);
1232 } 1286 }
1233 } 1287 }
1234 } 1288 }
@@ -1238,6 +1292,8 @@ controller_event_cb (void *cls,
1238 } 1292 }
1239 break; 1293 break;
1240 default: 1294 default:
1295 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1296 "Unexpected controller_cb with state %i!\n", state);
1241 GNUNET_assert (0); 1297 GNUNET_assert (0);
1242 } 1298 }
1243} 1299}
@@ -1539,9 +1595,9 @@ main (int argc, char *const *argv)
1539 {'d', "details", "FILENAME", 1595 {'d', "details", "FILENAME",
1540 gettext_noop ("name of the file for writing statistics"), 1596 gettext_noop ("name of the file for writing statistics"),
1541 1, &GNUNET_GETOPT_set_string, &data_filename}, 1597 1, &GNUNET_GETOPT_set_string, &data_filename},
1542 { 'n', "num-links", "COUNT", 1598 { 'n', "linking-factor", "FACTOR",
1543 gettext_noop ("create COUNT number of random links"), 1599 gettext_noop ("create FACTOR times number of peers random links"),
1544 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_links }, 1600 GNUNET_YES, &GNUNET_GETOPT_set_uint, &linking_factor },
1545 { 'e', "num-errors", "COUNT", 1601 { 'e', "num-errors", "COUNT",
1546 gettext_noop ("tolerate COUNT number of continious timeout failures"), 1602 gettext_noop ("tolerate COUNT number of continious timeout failures"),
1547 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails }, 1603 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails },
diff --git a/src/mesh/regex_profiler_test.conf b/src/mesh/regex_profiler_test.conf
index 697184829..1060ccdfc 100644
--- a/src/mesh/regex_profiler_test.conf
+++ b/src/mesh/regex_profiler_test.conf
@@ -3,8 +3,9 @@ AUTOSTART = NO
3PORT = 12000 3PORT = 12000
4ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; 4ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24;
5HOSTNAME = localhost 5HOSTNAME = localhost
6MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 5 6MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 200
7MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 5 7MAX_PARALLEL_OPERATIONS = 10000
8MAX_PARALLEL_SERVICE_CONNECTIONS = 10000
8 9
9[mesh] 10[mesh]
10AUTOSTART = YES 11AUTOSTART = YES