diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-30 12:20:10 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-30 12:20:10 +0000 |
commit | 2d9a0e6fda15a70eb87ca3a1e5b8088f440b8adb (patch) | |
tree | 4adc418d2c6030523b9524e214b512e273505488 /src/ats/perf_ats_solver.c | |
parent | 4af4e7f31e7aa94dbf2af61dba93fa8e8e377b60 (diff) | |
download | gnunet-2d9a0e6fda15a70eb87ca3a1e5b8088f440b8adb.tar.gz gnunet-2d9a0e6fda15a70eb87ca3a1e5b8088f440b8adb.zip |
basic benchmark functionality working
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r-- | src/ats/perf_ats_solver.c | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index e0675ecbf..5a229756b 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -32,9 +32,9 @@ | |||
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_PEERS_START 1 | 35 | #define DEFAULT_PEERS_START 10 |
36 | #define DEFAULT_PEERS_END 1 | 36 | #define DEFAULT_PEERS_END 10 |
37 | #define DEFAULT_ADDRESSES 1 | 37 | #define DEFAULT_ADDRESSES 10 |
38 | #define DEFAULT_ATS_COUNT 2 | 38 | #define DEFAULT_ATS_COUNT 2 |
39 | 39 | ||
40 | /** | 40 | /** |
@@ -64,6 +64,8 @@ struct PerfHandle | |||
64 | int opt_update_percent; | 64 | int opt_update_percent; |
65 | int opt_update_quantity; | 65 | int opt_update_quantity; |
66 | 66 | ||
67 | int bulk_running; | ||
68 | |||
67 | char *ats_string; | 69 | char *ats_string; |
68 | 70 | ||
69 | /** | 71 | /** |
@@ -163,7 +165,7 @@ perf_create_peer (int cp) | |||
163 | 165 | ||
164 | 166 | ||
165 | static void | 167 | static void |
166 | update_single_addresses (struct ATS_Address *cur) | 168 | perf_update_address (struct ATS_Address *cur) |
167 | { | 169 | { |
168 | int r_type; | 170 | int r_type; |
169 | int r_val; | 171 | int r_val; |
@@ -201,6 +203,18 @@ update_single_addresses (struct ATS_Address *cur) | |||
201 | static void | 203 | static void |
202 | bandwidth_changed_cb (void *cls, struct ATS_Address *address) | 204 | bandwidth_changed_cb (void *cls, struct ATS_Address *address) |
203 | { | 205 | { |
206 | if (0 == ntohl(address->assigned_bw_out.value__) && | ||
207 | 0 == ntohl(address->assigned_bw_in.value__)) | ||
208 | return; | ||
209 | |||
210 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
211 | "Bandwidth changed addresses %s %p to %llu Bps out / %llu Bps in\n", | ||
212 | GNUNET_i2s (&address->peer), | ||
213 | address, | ||
214 | ntohl(address->assigned_bw_out.value__), | ||
215 | ntohl(address->assigned_bw_in.value__)); | ||
216 | if (GNUNET_YES == ph.bulk_running) | ||
217 | GNUNET_break (0); | ||
204 | return; | 218 | return; |
205 | } | 219 | } |
206 | 220 | ||
@@ -225,7 +239,7 @@ normalized_property_changed_cb (void *cls, struct ATS_Address *peer, | |||
225 | } | 239 | } |
226 | 240 | ||
227 | static void | 241 | static void |
228 | address_initial_update (void *solver, | 242 | perf_address_initial_update (void *solver, |
229 | struct GNUNET_CONTAINER_MultiPeerMap * addresses, | 243 | struct GNUNET_CONTAINER_MultiPeerMap * addresses, |
230 | struct ATS_Address *address) | 244 | struct ATS_Address *address) |
231 | { | 245 | { |
@@ -241,7 +255,7 @@ address_initial_update (void *solver, | |||
241 | } | 255 | } |
242 | 256 | ||
243 | static void | 257 | static void |
244 | update_addresses (unsigned int cp, unsigned int ca, unsigned int up_q) | 258 | perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int up_q) |
245 | { | 259 | { |
246 | struct ATS_Address *cur; | 260 | struct ATS_Address *cur; |
247 | int c_peer; | 261 | int c_peer; |
@@ -274,7 +288,7 @@ update_addresses (unsigned int cp, unsigned int ca, unsigned int up_q) | |||
274 | for (cur = ph.peers[c_peer].head; NULL != cur; cur = cur->next) | 288 | for (cur = ph.peers[c_peer].head; NULL != cur; cur = cur->next) |
275 | { | 289 | { |
276 | if (1 == m[c_addr]) | 290 | if (1 == m[c_addr]) |
277 | update_single_addresses (cur); | 291 | perf_update_address (cur); |
278 | c_addr++; | 292 | c_addr++; |
279 | } | 293 | } |
280 | } | 294 | } |
@@ -302,8 +316,11 @@ perf_run () | |||
302 | int ca; | 316 | int ca; |
303 | int count_p = ph.N_peers_end; | 317 | int count_p = ph.N_peers_end; |
304 | int count_a = ph.N_address; | 318 | int count_a = ph.N_address; |
305 | int bulk_running; | ||
306 | struct ATS_Address * cur_addr; | 319 | struct ATS_Address * cur_addr; |
320 | struct GNUNET_TIME_Absolute start; | ||
321 | struct GNUNET_TIME_Absolute end; | ||
322 | struct GNUNET_TIME_Relative delta; | ||
323 | |||
307 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); | 324 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); |
308 | 325 | ||
309 | for (cp = 0; cp < count_p; cp++) | 326 | for (cp = 0; cp < count_p; cp++) |
@@ -313,39 +330,50 @@ perf_run () | |||
313 | 330 | ||
314 | /* Set initial bulk start to not solve */ | 331 | /* Set initial bulk start to not solve */ |
315 | ph.env.sf.s_bulk_start (ph.solver); | 332 | ph.env.sf.s_bulk_start (ph.solver); |
316 | bulk_running = GNUNET_YES; | 333 | ph.bulk_running = GNUNET_YES; |
317 | 334 | ||
318 | for (cp = 0; cp < count_p; cp++) | 335 | for (cp = 0; cp < count_p; cp++) |
319 | { | 336 | { |
320 | for (ca = 0; ca < count_a; ca++) | 337 | for (ca = 0; ca < count_a; ca++) |
321 | { | 338 | { |
322 | cur_addr = perf_create_address (cp, ca); | 339 | cur_addr = perf_create_address (cp, ca); |
323 | /* add address */ | 340 | /* Add address */ |
324 | ph.env.sf.s_add (ph.solver, cur_addr, GNUNET_ATS_NET_LAN); | 341 | ph.env.sf.s_add (ph.solver, cur_addr, GNUNET_ATS_NET_LAN); |
325 | address_initial_update (ph.solver, ph.addresses, cur_addr); | 342 | perf_address_initial_update (ph.solver, ph.addresses, cur_addr); |
326 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 343 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
327 | "Adding address for peer %u address %u\n", cp, ca); | 344 | "Adding address for peer %u address %u\n", cp, ca); |
328 | } | 345 | } |
346 | /* Notify solver about request */ | ||
329 | ph.env.sf.s_get (ph.solver, &ph.peers[cp].id); | 347 | ph.env.sf.s_get (ph.solver, &ph.peers[cp].id); |
330 | 348 | ||
331 | if (cp + 1 >= ph.N_peers_start) | 349 | if (cp + 1 >= ph.N_peers_start) |
332 | { | 350 | { |
333 | /* Disable bulk to solve the problem */ | 351 | /* Disable bulk to solve the problem */ |
334 | if (GNUNET_YES == bulk_running) | 352 | if (GNUNET_YES == ph.bulk_running) |
335 | { | 353 | { |
354 | start = GNUNET_TIME_absolute_get(); | ||
355 | ph.bulk_running = GNUNET_NO; | ||
336 | ph.env.sf.s_bulk_stop (ph.solver); | 356 | ph.env.sf.s_bulk_stop (ph.solver); |
337 | bulk_running = GNUNET_NO; | 357 | } |
358 | else | ||
359 | { | ||
360 | GNUNET_break (0); | ||
338 | } | 361 | } |
339 | 362 | ||
340 | /* Problem should be solved here */ | 363 | /* Problem is solved by the solver here due to unlocking */ |
341 | 364 | ||
342 | /* Disable bulk to solve the problem */ | 365 | /* Disable bulk to solve the problem */ |
343 | if (GNUNET_NO == bulk_running) | 366 | if (GNUNET_NO == ph.bulk_running) |
344 | { | 367 | { |
368 | |||
369 | end = GNUNET_TIME_absolute_get(); | ||
370 | delta = GNUNET_TIME_absolute_get_difference(start, end); | ||
371 | fprintf (stderr, "Solver took %llu us to solve problem with %u peers and %u addresses per peer\n", | ||
372 | (unsigned long long) delta.rel_value_us, | ||
373 | cp + 1, ca); | ||
345 | ph.env.sf.s_bulk_start (ph.solver); | 374 | ph.env.sf.s_bulk_start (ph.solver); |
346 | bulk_running = GNUNET_YES; | 375 | ph.bulk_running = GNUNET_YES; |
347 | } | 376 | } |
348 | |||
349 | #if 0 | 377 | #if 0 |
350 | if ((0 < ph.opt_update_quantity) || (0 < ph.opt_update_percent)) | 378 | if ((0 < ph.opt_update_quantity) || (0 < ph.opt_update_percent)) |
351 | { | 379 | { |
@@ -361,10 +389,10 @@ perf_run () | |||
361 | } | 389 | } |
362 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 390 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
363 | "Done, cleaning up addresses\n"); | 391 | "Done, cleaning up addresses\n"); |
364 | if (GNUNET_NO == bulk_running) | 392 | if (GNUNET_NO == ph.bulk_running) |
365 | { | 393 | { |
366 | ph.env.sf.s_bulk_start (ph.solver); | 394 | ph.env.sf.s_bulk_start (ph.solver); |
367 | bulk_running = GNUNET_YES; | 395 | ph.bulk_running = GNUNET_YES; |
368 | } | 396 | } |
369 | 397 | ||
370 | for (cp = 0; cp < count_p; cp++) | 398 | for (cp = 0; cp < count_p; cp++) |