From: Matthias Wachs Date: Tue, 17 Apr 2012 10:36:04 +0000 (+0000) Subject: - changes X-Git-Tag: initial-import-from-subversion-38251~13912 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=716899950996602e7bc249b2a752032272b5ec00;p=oweals%2Fgnunet.git - changes --- diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 33b7e32e5..9f0c6c6cd 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -806,6 +806,14 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas return res; } + +struct SolveContext +{ + struct GNUNET_TIME_Relative lp_duration; + struct GNUNET_TIME_Relative mlp_duration; +}; + + /** * Solves the LP problem * @@ -813,7 +821,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure */ static int -mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) +mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx) { int res; struct GNUNET_TIME_Relative duration; @@ -867,6 +875,7 @@ lp_solv: duration = GNUNET_TIME_absolute_get_difference (start, end); mlp->lp_solved++; mlp->lp_total_duration =+ duration.rel_value; + s_ctx->lp_duration = duration; GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO); GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO); @@ -906,7 +915,7 @@ lp_solv: * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure */ int -mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) +mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx) { int res; struct GNUNET_TIME_Relative duration; @@ -943,6 +952,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) duration = GNUNET_TIME_absolute_get_difference (start, end); mlp->mlp_solved++; mlp->mlp_total_duration =+ duration.rel_value; + s_ctx->mlp_duration = duration; GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO); GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO); @@ -989,7 +999,6 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GAS_mlp_solve_problem(mlp); } - /** * Solves the MLP problem * @@ -1000,11 +1009,10 @@ int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) { int res; + struct SolveContext s_ctx; mlp->last_execution = GNUNET_TIME_absolute_get (); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n"); - - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n"); #if WRITE_MLP char * name; static int i; @@ -1014,39 +1022,34 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) GNUNET_free (name); # endif - res = mlp_solve_lp_problem (mlp); - + res = mlp_solve_lp_problem (mlp, &s_ctx); + if (res != GNUNET_OK) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n"); + return GNUNET_SYSERR; + } #if WRITE_MLP GNUNET_asprintf(&name, "problem_%i_lp_solution", i); glp_print_sol (mlp->prob, name); GNUNET_free (name); # endif + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n"); + res = mlp_solve_mlp_problem (mlp, &s_ctx); if (res != GNUNET_OK) { - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n"); - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n"); return GNUNET_SYSERR; } - - res = mlp_solve_mlp_problem (mlp); - #if WRITE_MLP GNUNET_asprintf(&name, "problem_%i_mlp_solution", i); glp_print_mip (mlp->prob, name); GNUNET_free (name); # endif - if (res != GNUNET_OK) - { - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n"); - - return GNUNET_SYSERR; - } - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved %s (LP duration %llu / MLP duration %llu)\n", + (GNUNET_OK == res) ? "successfully" : "failed", s_ctx.lp_duration, s_ctx.mlp_duration); /* Process result */ struct ATS_Peer *p = NULL; struct ATS_Address *a = NULL; diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index 115fbf01a..f536419a7 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c @@ -88,7 +88,7 @@ check (void *cls, char *const *args, const char *cfgfile, if (addresses == 0) addresses = DEF_ADDRESSES_PER_PEER; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses); struct PeerContext p[peers]; struct ATS_Address a[addresses * peers]; @@ -99,12 +99,12 @@ check (void *cls, char *const *args, const char *cfgfile, mlp->auto_solve = GNUNET_NO; for (c=0; c < peers; c++) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up peer %u\n", c); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c); GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[c].id.hashPubKey); for (c2=0; c2 < addresses; c2++) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer %u\n", c2, c); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u for peer %u\n", c2, c); /* Setting required information */ a[ca].mlp_information = NULL; a[ca].prev = NULL; @@ -123,20 +123,25 @@ check (void *cls, char *const *args, const char *cfgfile, a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE; a[ca].ats[1].value = 2; a[ca].ats_count = 2; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u\n", ca); GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); GAS_mlp_address_update(mlp, amap, &a[ca]); - ca++; } } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); /* Solving the problem */ - //GAS_mlp_solve_problem(mlp); + if (GNUNET_OK == GAS_mlp_solve_problem(mlp)) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n"); + else + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved failed \n"); GAS_mlp_done (mlp); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution duration %llu\n", mlp->max_exec_duration); + + for (ca=0; ca < (peers * addresses); ca++) { GNUNET_free (a[ca].plugin);