diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
commit | 502af2167f7c218366666ca4944bd7cc54b5b19a (patch) | |
tree | a91fec5cc9769d260640bd91c6633cb9cf395524 /src/fs/perf_gnunet_service_fs_p2p.c | |
parent | 03af5a603b7cc53432249d5854cd412aa90dde0d (diff) | |
download | gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip |
indentation
Diffstat (limited to 'src/fs/perf_gnunet_service_fs_p2p.c')
-rw-r--r-- | src/fs/perf_gnunet_service_fs_p2p.c | 284 |
1 files changed, 126 insertions, 158 deletions
diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c index 572585520..92441e901 100644 --- a/src/fs/perf_gnunet_service_fs_p2p.c +++ b/src/fs/perf_gnunet_service_fs_p2p.c | |||
@@ -52,11 +52,9 @@ static struct GNUNET_TIME_Absolute start_time; | |||
52 | static const char *progname; | 52 | static const char *progname; |
53 | 53 | ||
54 | static void | 54 | static void |
55 | do_stop (void *cls, | 55 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
56 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
57 | { | 56 | { |
58 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, | 57 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); |
59 | daemons); | ||
60 | } | 58 | } |
61 | 59 | ||
62 | 60 | ||
@@ -65,7 +63,7 @@ do_stop (void *cls, | |||
65 | */ | 63 | */ |
66 | struct StatMaster | 64 | struct StatMaster |
67 | { | 65 | { |
68 | struct GNUNET_STATISTICS_Handle *stat; | 66 | struct GNUNET_STATISTICS_Handle *stat; |
69 | unsigned int daemon; | 67 | unsigned int daemon; |
70 | unsigned int value; | 68 | unsigned int value; |
71 | }; | 69 | }; |
@@ -79,32 +77,31 @@ struct StatValues | |||
79 | /** | 77 | /** |
80 | * Statistics we print out. | 78 | * Statistics we print out. |
81 | */ | 79 | */ |
82 | static struct StatValues stats[] = | 80 | static struct StatValues stats[] = { |
83 | { | 81 | {"fs", "# artificial delays introduced (ms)"}, |
84 | { "fs", "# artificial delays introduced (ms)"}, | 82 | {"fs", "# queries forwarded"}, |
85 | { "fs", "# queries forwarded"}, | 83 | {"fs", "# replies received and matched"}, |
86 | { "fs", "# replies received and matched"}, | 84 | {"fs", "# results found locally"}, |
87 | { "fs", "# results found locally"}, | 85 | {"fs", "# requests forwarded due to high load"}, |
88 | { "fs", "# requests forwarded due to high load"}, | 86 | {"fs", "# requests done for free (low load)"}, |
89 | { "fs", "# requests done for free (low load)"}, | 87 | {"fs", "# requests dropped, priority insufficient"}, |
90 | { "fs", "# requests dropped, priority insufficient"}, | 88 | {"fs", "# requests done for a price (normal load)"}, |
91 | { "fs", "# requests done for a price (normal load)"}, | 89 | {"fs", "# requests dropped by datastore (queue length limit)"}, |
92 | { "fs", "# requests dropped by datastore (queue length limit)"}, | 90 | {"fs", "# P2P searches received"}, |
93 | { "fs", "# P2P searches received"}, | 91 | {"fs", "# P2P searches discarded (queue length bound)"}, |
94 | { "fs", "# P2P searches discarded (queue length bound)"}, | 92 | {"fs", "# replies received for local clients"}, |
95 | { "fs", "# replies received for local clients"}, | 93 | {"fs", "# queries retransmitted to same target"}, |
96 | { "fs", "# queries retransmitted to same target"}, | 94 | {"core", "# bytes decrypted"}, |
97 | { "core", "# bytes decrypted"}, | 95 | {"core", "# bytes encrypted"}, |
98 | { "core", "# bytes encrypted"}, | 96 | {"core", "# discarded CORE_SEND requests"}, |
99 | { "core", "# discarded CORE_SEND requests"}, | 97 | {"core", "# discarded CORE_SEND request bytes"}, |
100 | { "core", "# discarded CORE_SEND request bytes"}, | 98 | {"core", "# discarded lower priority CORE_SEND requests"}, |
101 | { "core", "# discarded lower priority CORE_SEND requests"}, | 99 | {"core", "# discarded lower priority CORE_SEND request bytes"}, |
102 | { "core", "# discarded lower priority CORE_SEND request bytes"}, | 100 | {"transport", "# bytes received via TCP"}, |
103 | { "transport", "# bytes received via TCP"}, | 101 | {"transport", "# bytes transmitted via TCP"}, |
104 | { "transport", "# bytes transmitted via TCP"}, | 102 | {"datacache", "# bytes stored"}, |
105 | { "datacache", "# bytes stored"}, | 103 | {NULL, NULL} |
106 | { NULL, NULL} | 104 | }; |
107 | }; | ||
108 | 105 | ||
109 | 106 | ||
110 | /** | 107 | /** |
@@ -119,18 +116,14 @@ static struct StatValues stats[] = | |||
119 | */ | 116 | */ |
120 | static int | 117 | static int |
121 | print_stat (void *cls, | 118 | print_stat (void *cls, |
122 | const char *subsystem, | 119 | const char *subsystem, |
123 | const char *name, | 120 | const char *name, uint64_t value, int is_persistent) |
124 | uint64_t value, | ||
125 | int is_persistent) | ||
126 | { | 121 | { |
127 | struct StatMaster *sm = cls; | 122 | struct StatMaster *sm = cls; |
123 | |||
128 | fprintf (stderr, | 124 | fprintf (stderr, |
129 | "Peer %2u: %12s/%50s = %12llu\n", | 125 | "Peer %2u: %12s/%50s = %12llu\n", |
130 | sm->daemon, | 126 | sm->daemon, subsystem, name, (unsigned long long) value); |
131 | subsystem, | ||
132 | name, | ||
133 | (unsigned long long) value); | ||
134 | return GNUNET_OK; | 127 | return GNUNET_OK; |
135 | } | 128 | } |
136 | 129 | ||
@@ -138,20 +131,18 @@ print_stat (void *cls, | |||
138 | /** | 131 | /** |
139 | * Function that gathers stats from all daemons. | 132 | * Function that gathers stats from all daemons. |
140 | */ | 133 | */ |
141 | static void | 134 | static void stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
142 | stat_run (void *cls, | ||
143 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
144 | 135 | ||
145 | 136 | ||
146 | /** | 137 | /** |
147 | * Function called when GET operation on stats is done. | 138 | * Function called when GET operation on stats is done. |
148 | */ | 139 | */ |
149 | static void | 140 | static void |
150 | get_done (void *cls, | 141 | get_done (void *cls, int success) |
151 | int success) | ||
152 | { | 142 | { |
153 | struct StatMaster *sm = cls; | 143 | struct StatMaster *sm = cls; |
154 | GNUNET_break (GNUNET_OK == success); | 144 | |
145 | GNUNET_break (GNUNET_OK == success); | ||
155 | sm->value++; | 146 | sm->value++; |
156 | GNUNET_SCHEDULER_add_now (&stat_run, sm); | 147 | GNUNET_SCHEDULER_add_now (&stat_run, sm); |
157 | } | 148 | } |
@@ -161,129 +152,115 @@ get_done (void *cls, | |||
161 | * Function that gathers stats from all daemons. | 152 | * Function that gathers stats from all daemons. |
162 | */ | 153 | */ |
163 | static void | 154 | static void |
164 | stat_run (void *cls, | 155 | stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
165 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
166 | { | 156 | { |
167 | struct StatMaster *sm = cls; | 157 | struct StatMaster *sm = cls; |
168 | 158 | ||
169 | if (stats[sm->value].name != NULL) | 159 | if (stats[sm->value].name != NULL) |
170 | { | 160 | { |
171 | GNUNET_STATISTICS_get (sm->stat, | 161 | GNUNET_STATISTICS_get (sm->stat, |
172 | #if 0 | 162 | #if 0 |
173 | NULL, NULL, | 163 | NULL, NULL, |
174 | #else | 164 | #else |
175 | stats[sm->value].subsystem, | 165 | stats[sm->value].subsystem, stats[sm->value].name, |
176 | stats[sm->value].name, | ||
177 | #endif | 166 | #endif |
178 | GNUNET_TIME_UNIT_FOREVER_REL, | 167 | GNUNET_TIME_UNIT_FOREVER_REL, |
179 | &get_done, | 168 | &get_done, &print_stat, sm); |
180 | &print_stat, sm); | 169 | return; |
181 | return; | 170 | } |
182 | } | ||
183 | GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); | 171 | GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); |
184 | sm->value = 0; | 172 | sm->value = 0; |
185 | sm->daemon++; | 173 | sm->daemon++; |
186 | if (sm->daemon == NUM_DAEMONS) | 174 | if (sm->daemon == NUM_DAEMONS) |
187 | { | 175 | { |
188 | GNUNET_free (sm); | 176 | GNUNET_free (sm); |
189 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); | 177 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
190 | return; | 178 | return; |
191 | } | 179 | } |
192 | sm->stat = GNUNET_STATISTICS_create ("<driver>", | 180 | sm->stat = GNUNET_STATISTICS_create ("<driver>", |
193 | GNUNET_FS_TEST_get_configuration (daemons, | 181 | GNUNET_FS_TEST_get_configuration |
194 | sm->daemon)); | 182 | (daemons, sm->daemon)); |
195 | GNUNET_SCHEDULER_add_now (&stat_run, sm); | 183 | GNUNET_SCHEDULER_add_now (&stat_run, sm); |
196 | } | 184 | } |
197 | 185 | ||
198 | 186 | ||
199 | static void | 187 | static void |
200 | do_report (void *cls, | 188 | do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
201 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
202 | { | 189 | { |
203 | struct GNUNET_TIME_Relative del; | 190 | struct GNUNET_TIME_Relative del; |
204 | char *fancy; | 191 | char *fancy; |
205 | struct StatMaster *sm; | 192 | struct StatMaster *sm; |
206 | 193 | ||
207 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 194 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
208 | { | 195 | { |
209 | del = GNUNET_TIME_absolute_get_duration (start_time); | 196 | del = GNUNET_TIME_absolute_get_duration (start_time); |
210 | if (del.rel_value == 0) | 197 | if (del.rel_value == 0) |
211 | del.rel_value = 1; | 198 | del.rel_value = 1; |
212 | fancy = GNUNET_STRINGS_byte_size_fancy (((unsigned long long)FILESIZE) * 1000LL / del.rel_value); | 199 | fancy = |
213 | fprintf (stdout, | 200 | GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) * |
214 | "Download speed was %s/s\n", | 201 | 1000LL / del.rel_value); |
215 | fancy); | 202 | fprintf (stdout, "Download speed was %s/s\n", fancy); |
216 | GNUNET_free (fancy); | 203 | GNUNET_free (fancy); |
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
218 | "Finished download, shutting down\n", | 205 | "Finished download, shutting down\n", |
219 | (unsigned long long) FILESIZE); | 206 | (unsigned long long) FILESIZE); |
220 | sm = GNUNET_malloc (sizeof (struct StatMaster)); | 207 | sm = GNUNET_malloc (sizeof (struct StatMaster)); |
221 | sm->stat = GNUNET_STATISTICS_create ("<driver>", | 208 | sm->stat = GNUNET_STATISTICS_create ("<driver>", |
222 | GNUNET_FS_TEST_get_configuration (daemons, | 209 | GNUNET_FS_TEST_get_configuration |
223 | sm->daemon)); | 210 | (daemons, sm->daemon)); |
224 | GNUNET_SCHEDULER_add_now (&stat_run, sm); | 211 | GNUNET_SCHEDULER_add_now (&stat_run, sm); |
225 | } | 212 | } |
226 | else | 213 | else |
227 | { | 214 | { |
228 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 215 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
229 | "Timeout during download, shutting down with error\n"); | 216 | "Timeout during download, shutting down with error\n"); |
230 | ok = 1; | 217 | ok = 1; |
231 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); | 218 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
232 | } | 219 | } |
233 | } | 220 | } |
234 | 221 | ||
235 | 222 | ||
236 | static void | 223 | static void |
237 | do_download (void *cls, | 224 | do_download (void *cls, const struct GNUNET_FS_Uri *uri) |
238 | const struct GNUNET_FS_Uri *uri) | ||
239 | { | 225 | { |
240 | int anonymity; | 226 | int anonymity; |
241 | 227 | ||
242 | if (NULL == uri) | 228 | if (NULL == uri) |
243 | { | 229 | { |
244 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, | 230 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); |
245 | daemons); | 231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 232 | "Timeout during upload attempt, shutting down with error\n"); |
247 | "Timeout during upload attempt, shutting down with error\n"); | 233 | ok = 1; |
248 | ok = 1; | 234 | return; |
249 | return; | 235 | } |
250 | } | ||
251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
252 | "Downloading %llu bytes\n", | 237 | "Downloading %llu bytes\n", (unsigned long long) FILESIZE); |
253 | (unsigned long long) FILESIZE); | ||
254 | start_time = GNUNET_TIME_absolute_get (); | 238 | start_time = GNUNET_TIME_absolute_get (); |
255 | if (NULL != strstr (progname, "dht")) | 239 | if (NULL != strstr (progname, "dht")) |
256 | anonymity = 0; | 240 | anonymity = 0; |
257 | else | 241 | else |
258 | anonymity = 1; | 242 | anonymity = 1; |
259 | GNUNET_FS_TEST_download (daemons[0], | 243 | GNUNET_FS_TEST_download (daemons[0], |
260 | TIMEOUT, | 244 | TIMEOUT, |
261 | anonymity, SEED, uri, | 245 | anonymity, SEED, uri, VERBOSE, &do_report, NULL); |
262 | VERBOSE, | ||
263 | &do_report, NULL); | ||
264 | } | 246 | } |
265 | 247 | ||
266 | 248 | ||
267 | static void | 249 | static void |
268 | do_publish (void *cls, | 250 | do_publish (void *cls, const char *emsg) |
269 | const char *emsg) | ||
270 | { | 251 | { |
271 | int do_index; | 252 | int do_index; |
272 | int anonymity; | 253 | int anonymity; |
273 | 254 | ||
274 | if (NULL != emsg) | 255 | if (NULL != emsg) |
275 | { | 256 | { |
276 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, | 257 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); |
277 | daemons); | 258 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error trying to connect: %s\n", emsg); |
278 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 259 | ok = 1; |
279 | "Error trying to connect: %s\n", | 260 | return; |
280 | emsg); | 261 | } |
281 | ok = 1; | ||
282 | return; | ||
283 | } | ||
284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
285 | "Publishing %llu bytes\n", | 263 | "Publishing %llu bytes\n", (unsigned long long) FILESIZE); |
286 | (unsigned long long) FILESIZE); | ||
287 | if (NULL != strstr (progname, "index")) | 264 | if (NULL != strstr (progname, "index")) |
288 | do_index = GNUNET_YES; | 265 | do_index = GNUNET_YES; |
289 | else | 266 | else |
@@ -292,61 +269,52 @@ do_publish (void *cls, | |||
292 | anonymity = 0; | 269 | anonymity = 0; |
293 | else | 270 | else |
294 | anonymity = 1; | 271 | anonymity = 1; |
295 | 272 | ||
296 | GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS-1], | 273 | GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], |
297 | TIMEOUT, | 274 | TIMEOUT, |
298 | anonymity, | 275 | anonymity, |
299 | do_index, FILESIZE, SEED, | 276 | do_index, FILESIZE, SEED, |
300 | VERBOSE, | 277 | VERBOSE, &do_download, NULL); |
301 | &do_download, NULL); | ||
302 | } | 278 | } |
303 | 279 | ||
304 | 280 | ||
305 | static void | 281 | static void |
306 | do_connect (void *cls, | 282 | do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
307 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
308 | { | 283 | { |
309 | struct GNUNET_TESTING_PeerGroup *pg; | 284 | struct GNUNET_TESTING_PeerGroup *pg; |
310 | 285 | ||
311 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 286 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
313 | "Daemons started, will now try to connect them\n"); | 288 | "Daemons started, will now try to connect them\n"); |
314 | pg = GNUNET_FS_TEST_get_group (daemons); | 289 | pg = GNUNET_FS_TEST_get_group (daemons); |
315 | GNUNET_break ( (NUM_DAEMONS - 1) * 2 | 290 | GNUNET_break ((NUM_DAEMONS - 1) * 2 |
316 | == (GNUNET_TESTING_create_topology (pg, | 291 | == (GNUNET_TESTING_create_topology (pg, |
317 | GNUNET_TESTING_TOPOLOGY_LINE, | 292 | GNUNET_TESTING_TOPOLOGY_LINE, |
318 | GNUNET_TESTING_TOPOLOGY_NONE, | 293 | GNUNET_TESTING_TOPOLOGY_NONE, |
319 | NULL))); | 294 | NULL))); |
320 | GNUNET_TESTING_connect_topology (pg, | 295 | GNUNET_TESTING_connect_topology (pg, |
321 | GNUNET_TESTING_TOPOLOGY_LINE, | 296 | GNUNET_TESTING_TOPOLOGY_LINE, |
322 | GNUNET_TESTING_TOPOLOGY_OPTION_NONE, | 297 | GNUNET_TESTING_TOPOLOGY_OPTION_NONE, |
323 | 0.0, | 298 | 0.0, |
324 | TIMEOUT, | 299 | TIMEOUT, NUM_DAEMONS, &do_publish, NULL); |
325 | NUM_DAEMONS, | ||
326 | &do_publish, | ||
327 | NULL); | ||
328 | } | 300 | } |
329 | 301 | ||
330 | 302 | ||
331 | static void | 303 | static void |
332 | run (void *cls, | 304 | run (void *cls, |
333 | char *const *args, | 305 | char *const *args, |
334 | const char *cfgfile, | 306 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
335 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
336 | { | 307 | { |
337 | GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", | 308 | GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", |
338 | TIMEOUT, | 309 | TIMEOUT, |
339 | NUM_DAEMONS, | 310 | NUM_DAEMONS, daemons, &do_connect, NULL); |
340 | daemons, | ||
341 | &do_connect, | ||
342 | NULL); | ||
343 | } | 311 | } |
344 | 312 | ||
345 | 313 | ||
346 | int | 314 | int |
347 | main (int argc, char *argv[]) | 315 | main (int argc, char *argv[]) |
348 | { | 316 | { |
349 | char *const argvx[] = { | 317 | char *const argvx[] = { |
350 | "perf-gnunet-service-fs-p2p", | 318 | "perf-gnunet-service-fs-p2p", |
351 | "-c", | 319 | "-c", |
352 | "fs_test_lib_data.conf", | 320 | "fs_test_lib_data.conf", |
@@ -360,16 +328,16 @@ main (int argc, char *argv[]) | |||
360 | }; | 328 | }; |
361 | progname = argv[0]; | 329 | progname = argv[0]; |
362 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 330 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
363 | GNUNET_log_setup ("perf_gnunet_service_fs_p2p_index", | 331 | GNUNET_log_setup ("perf_gnunet_service_fs_p2p_index", |
364 | #if VERBOSE | 332 | #if VERBOSE |
365 | "DEBUG", | 333 | "DEBUG", |
366 | #else | 334 | #else |
367 | "WARNING", | 335 | "WARNING", |
368 | #endif | 336 | #endif |
369 | NULL); | 337 | NULL); |
370 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 338 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, |
371 | argvx, "perf-gnunet-service-fs-p2p-index", | 339 | argvx, "perf-gnunet-service-fs-p2p-index", |
372 | "nohelp", options, &run, NULL); | 340 | "nohelp", options, &run, NULL); |
373 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 341 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
374 | return ok; | 342 | return ok; |
375 | } | 343 | } |