diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-11-02 19:35:00 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-11-02 19:35:00 +0000 |
commit | 9ae7e7fd73793dfbdcd8877c4f44ccaaeccfbdbb (patch) | |
tree | 207212673b433c3c2a3c7a7045024cfe8e466e54 /src | |
parent | 60368fd5d0d4131a1bf78454015a6edd7b9a626d (diff) | |
download | gnunet-9ae7e7fd73793dfbdcd8877c4f44ccaaeccfbdbb.tar.gz gnunet-9ae7e7fd73793dfbdcd8877c4f44ccaaeccfbdbb.zip |
regex profiler fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-regex-profiler.c | 121 |
1 files changed, 77 insertions, 44 deletions
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c index 536eacccf..28af3b476 100644 --- a/src/mesh/gnunet-regex-profiler.c +++ b/src/mesh/gnunet-regex-profiler.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /** |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
@@ -339,6 +339,16 @@ static struct GNUNET_TIME_Relative search_timeout = { 60000 }; | |||
339 | static struct GNUNET_TIME_Relative search_delay = { 60000 }; | 339 | static struct GNUNET_TIME_Relative search_delay = { 60000 }; |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * Delay before setting mesh service op as done. | ||
343 | */ | ||
344 | static struct GNUNET_TIME_Relative mesh_done_delay = { 1000 }; | ||
345 | |||
346 | /** | ||
347 | * Delay to wait before starting to configure the overlay topology | ||
348 | */ | ||
349 | static struct GNUNET_TIME_Relative conf_topo_delay = { 10000 }; | ||
350 | |||
351 | /** | ||
342 | * File to log statistics to. | 352 | * File to log statistics to. |
343 | */ | 353 | */ |
344 | static struct GNUNET_DISK_FileHandle *data_file; | 354 | static struct GNUNET_DISK_FileHandle *data_file; |
@@ -353,11 +363,6 @@ static char *data_filename; | |||
353 | */ | 363 | */ |
354 | static unsigned int max_path_compression; | 364 | static unsigned int max_path_compression; |
355 | 365 | ||
356 | /** | ||
357 | * Delay before setting mesh service op as done. | ||
358 | */ | ||
359 | static struct GNUNET_TIME_Relative mesh_done_delay = { 1000 }; | ||
360 | |||
361 | /******************************************************************************/ | 366 | /******************************************************************************/ |
362 | /****************************** DECLARATIONS ********************************/ | 367 | /****************************** DECLARATIONS ********************************/ |
363 | /******************************************************************************/ | 368 | /******************************************************************************/ |
@@ -604,7 +609,8 @@ stats_cb (void *cls, | |||
604 | 609 | ||
605 | if (++peer_cnt == num_search_strings) | 610 | if (++peer_cnt == num_search_strings) |
606 | { | 611 | { |
607 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 612 | struct GNUNET_TIME_Relative delay = { 100 }; |
613 | GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL); | ||
608 | } | 614 | } |
609 | } | 615 | } |
610 | 616 | ||
@@ -744,6 +750,9 @@ mesh_peer_connect_handler (void *cls, | |||
744 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 750 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
745 | "String matching timed out for string %s on peer %u (%i/%i)\n", | 751 | "String matching timed out for string %s on peer %u (%i/%i)\n", |
746 | peer->search_str, peer->id, peers_found, num_search_strings); | 752 | peer->search_str, peer->id, peers_found, num_search_strings); |
753 | |||
754 | printf ("String matching timed out for string %s on peer %u (%i/%i)\n", | ||
755 | peer->search_str, peer->id, peers_found, num_search_strings); | ||
747 | } | 756 | } |
748 | else | 757 | else |
749 | { | 758 | { |
@@ -897,8 +906,22 @@ do_mesh_op_done (void *cls, | |||
897 | const struct GNUNET_SCHEDULER_TaskContext * tc) | 906 | const struct GNUNET_SCHEDULER_TaskContext * tc) |
898 | { | 907 | { |
899 | struct RegexPeer *peer = cls; | 908 | struct RegexPeer *peer = cls; |
909 | static unsigned int peer_cnt; | ||
900 | GNUNET_TESTBED_operation_done (peer->mesh_op_handle); | 910 | GNUNET_TESTBED_operation_done (peer->mesh_op_handle); |
901 | peer->mesh_op_handle = NULL; | 911 | peer->mesh_op_handle = NULL; |
912 | |||
913 | if (++peer_cnt < num_peers) | ||
914 | { | ||
915 | peers[peer_cnt].mesh_op_handle = | ||
916 | GNUNET_TESTBED_service_connect (NULL, | ||
917 | peers[peer_cnt].peer_handle, | ||
918 | "mesh", | ||
919 | &mesh_connect_cb, | ||
920 | &peers[peer_cnt], | ||
921 | &mesh_ca, | ||
922 | &mesh_da, | ||
923 | &peers[peer_cnt]); | ||
924 | } | ||
902 | } | 925 | } |
903 | 926 | ||
904 | 927 | ||
@@ -914,7 +937,6 @@ void | |||
914 | mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | 937 | mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, |
915 | void *ca_result, const char *emsg) | 938 | void *ca_result, const char *emsg) |
916 | { | 939 | { |
917 | static unsigned int peer_cnt; | ||
918 | struct RegexPeer *peer = (struct RegexPeer *) cls; | 940 | struct RegexPeer *peer = (struct RegexPeer *) cls; |
919 | char *regex; | 941 | char *regex; |
920 | char *data; | 942 | char *data; |
@@ -987,19 +1009,6 @@ mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
987 | 1009 | ||
988 | GNUNET_SCHEDULER_add_delayed (mesh_done_delay, &do_mesh_op_done, peer); | 1010 | GNUNET_SCHEDULER_add_delayed (mesh_done_delay, &do_mesh_op_done, peer); |
989 | 1011 | ||
990 | if (++peer_cnt < num_peers) | ||
991 | { | ||
992 | peers[peer_cnt].mesh_op_handle = | ||
993 | GNUNET_TESTBED_service_connect (NULL, | ||
994 | peers[peer_cnt].peer_handle, | ||
995 | "mesh", | ||
996 | &mesh_connect_cb, | ||
997 | &peers[peer_cnt], | ||
998 | &mesh_ca, | ||
999 | &mesh_da, | ||
1000 | &peers[peer_cnt]); | ||
1001 | } | ||
1002 | |||
1003 | if (++num_files_announced == num_peers) | 1012 | if (++num_files_announced == num_peers) |
1004 | { | 1013 | { |
1005 | state = STATE_SEARCH_REGEX; | 1014 | state = STATE_SEARCH_REGEX; |
@@ -1103,6 +1112,41 @@ mesh_da (void *cls, void *op_result) | |||
1103 | 1112 | ||
1104 | 1113 | ||
1105 | /** | 1114 | /** |
1115 | * Configure the peer overlay topology. | ||
1116 | * | ||
1117 | * @param cls NULL | ||
1118 | * @param tc the task context | ||
1119 | */ | ||
1120 | static void | ||
1121 | do_configure_topology (void *cls, | ||
1122 | const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
1123 | { | ||
1124 | /* | ||
1125 | if (0 == linking_factor) | ||
1126 | linking_factor = 1; | ||
1127 | num_links = linking_factor * num_peers; | ||
1128 | */ | ||
1129 | /* num_links = num_peers - 1; */ | ||
1130 | num_links = linking_factor; | ||
1131 | |||
1132 | /* Do overlay connect */ | ||
1133 | prof_start_time = GNUNET_TIME_absolute_get (); | ||
1134 | topology_op = | ||
1135 | GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peer_handles, | ||
1136 | GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, | ||
1137 | num_links, | ||
1138 | GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY, | ||
1139 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | ||
1140 | if (NULL == topology_op) | ||
1141 | { | ||
1142 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1143 | "Cannot create topology, op handle was NULL\n"); | ||
1144 | GNUNET_assert (0); | ||
1145 | } | ||
1146 | } | ||
1147 | |||
1148 | |||
1149 | /** | ||
1106 | * Functions of this signature are called when a peer has been successfully | 1150 | * Functions of this signature are called when a peer has been successfully |
1107 | * started or stopped. | 1151 | * started or stopped. |
1108 | * | 1152 | * |
@@ -1143,28 +1187,16 @@ peer_churn_cb (void *cls, const char *emsg) | |||
1143 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) | 1187 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) |
1144 | peer_handles[peer_cnt] = peers[peer_cnt].peer_handle; | 1188 | peer_handles[peer_cnt] = peers[peer_cnt].peer_handle; |
1145 | 1189 | ||
1146 | /* | 1190 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1147 | if (0 == linking_factor) | 1191 | "Waiting %s before starting to link peers\n", |
1148 | linking_factor = 1; | 1192 | GNUNET_STRINGS_relative_time_to_string (conf_topo_delay, GNUNET_YES)); |
1149 | num_links = linking_factor * num_peers; | 1193 | |
1150 | */ | 1194 | printf ("Waiting %s before starting to link peers\n", |
1151 | /* num_links = num_peers - 1; */ | 1195 | GNUNET_STRINGS_relative_time_to_string (conf_topo_delay, GNUNET_YES)); |
1152 | num_links = linking_factor; | 1196 | fflush (stdout); |
1197 | |||
1153 | state = STATE_PEERS_LINKING; | 1198 | state = STATE_PEERS_LINKING; |
1154 | /* Do overlay connect */ | 1199 | GNUNET_SCHEDULER_add_delayed (conf_topo_delay, &do_configure_topology, NULL); |
1155 | prof_start_time = GNUNET_TIME_absolute_get (); | ||
1156 | topology_op = | ||
1157 | GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peer_handles, | ||
1158 | GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, | ||
1159 | num_links, | ||
1160 | GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY, | ||
1161 | GNUNET_TESTBED_TOPOLOGY_OPTION_END); | ||
1162 | if (NULL == topology_op) | ||
1163 | { | ||
1164 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1165 | "Cannot create topology, op handle was NULL\n"); | ||
1166 | GNUNET_assert (0); | ||
1167 | } | ||
1168 | } | 1200 | } |
1169 | } | 1201 | } |
1170 | 1202 | ||
@@ -1401,12 +1433,13 @@ controller_event_cb (void *cls, | |||
1401 | sizeof (output_buffer), | 1433 | sizeof (output_buffer), |
1402 | "# of peers: %u\n# of links established: %u\n" | 1434 | "# of peers: %u\n# of links established: %u\n" |
1403 | "Time to establish links: %s\nLinking failures: %u\n" | 1435 | "Time to establish links: %s\nLinking failures: %u\n" |
1404 | "path compression length: %u\n", | 1436 | "path compression length: %u\n# of search strings: %u\n", |
1405 | num_peers, | 1437 | num_peers, |
1406 | (established_links - cont_fails), | 1438 | (established_links - cont_fails), |
1407 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), | 1439 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO), |
1408 | cont_fails, | 1440 | cont_fails, |
1409 | max_path_compression); | 1441 | max_path_compression, |
1442 | num_search_strings); | ||
1410 | 1443 | ||
1411 | if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) | 1444 | if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) |
1412 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | 1445 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); |