From: Matthias Wachs Date: Tue, 26 Feb 2013 15:07:40 +0000 (+0000) Subject: performance analysis X-Git-Tag: initial-import-from-subversion-38251~9835 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9c27f52e1ccb192b84a5305eb10d9f159a6f26c6;p=oweals%2Fgnunet.git performance analysis --- diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index fc1bdf2e0..955a9cedd 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -895,14 +895,17 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas /* last +1 caused by glpk index starting with one: [1..elements]*/ p->ci = 1; /* row index */ - int *ia = GNUNET_malloc (p->num_elements * sizeof (int)); - p->ia = ia; + p->ia = GNUNET_malloc (p->num_elements * sizeof (int)); /* column index */ - int *ja = GNUNET_malloc (p->num_elements * sizeof (int)); - p->ja = ja; + p->ja = GNUNET_malloc (p->num_elements * sizeof (int)); /* coefficient */ - double *ar= GNUNET_malloc (p->num_elements * sizeof (double)); - p->ar = ar; + p->ar = GNUNET_malloc (p->num_elements * sizeof (double)); + + if ((NULL == p->ia) || (NULL == p->ja) || (NULL == p->ar)) + { + LOG (GNUNET_ERROR_TYPE_ERROR, _("Problem size too large, cannot allocate memory!\n")); + return GNUNET_SYSERR; + } /* Adding invariant columns */ mlp_create_problem_add_invariant_columns (mlp, p); @@ -930,22 +933,12 @@ static int mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) { int res = 0; - if (GNUNET_YES == mlp->mlp_prob_changed) - { - /* Problem was recreated: use LP presolver */ - mlp->control_param_lp.presolve = GLP_ON; - } - else - { - /* Problem was not recreated: do not use LP presolver */ - mlp->control_param_lp.presolve = GLP_OFF; - } res = glp_simplex(mlp->p.prob, &mlp->control_param_lp); if (0 == res) LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem: 0x%02X %s\n", res, mlp_solve_to_string(res)); else - LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res)); + LOG (GNUNET_ERROR_TYPE_WARNING, "Solving LP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res)); /* Analyze problem status */ res = glp_get_status (mlp->p.prob); @@ -959,7 +952,7 @@ mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) return GNUNET_OK; /* Problem was ill-defined, no way to handle that */ default: - LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem failed, no solution: 0x%02X %s\n", + LOG (GNUNET_ERROR_TYPE_WARNING, "Solving LP problem failed, no solution: 0x%02X %s\n", res, mlp_status_to_string(res)); return GNUNET_SYSERR; } @@ -980,7 +973,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) if (0 == res) LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem: 0x%02X %s\n", res, mlp_solve_to_string(res)); else - LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res)); + LOG (GNUNET_ERROR_TYPE_WARNING, "Solving MLP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res)); /* Analyze problem status */ res = glp_mip_status(mlp->p.prob); switch (res) { @@ -992,7 +985,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) return GNUNET_OK; /* Problem was ill-defined, no way to handle that */ default: - LOG (GNUNET_ERROR_TYPE_DEBUG,"Solving MLP problem failed, 0x%02X %s\n\n", res, mlp_status_to_string(res)); + LOG (GNUNET_ERROR_TYPE_WARNING,"Solving MLP problem failed, 0x%02X %s\n\n", res, mlp_status_to_string(res)); return GNUNET_SYSERR; } } @@ -1092,9 +1085,11 @@ GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addr LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); mlp_delete_problem (mlp); start_build = GNUNET_TIME_absolute_get(); - mlp_create_problem (mlp, addresses); + if (GNUNET_SYSERR == mlp_create_problem (mlp, addresses)) + return GNUNET_SYSERR; duration_build = GNUNET_TIME_absolute_get_duration (start_build); mlp->control_param_lp.presolve = GLP_YES; + mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ } else { @@ -1120,6 +1115,11 @@ GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addr mlp->ps.build_dur = duration_build; mlp->ps.lp_dur = duration_lp; mlp->ps.mip_dur = duration_mlp; + mlp->ps.lp_presolv = mlp->control_param_lp.presolve; + mlp->ps.mip_presolv = mlp->control_param_mlp.presolve; + mlp->ps.p_cols = glp_get_num_cols (mlp->p.prob); + mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob); + mlp->ps.p_elements = mlp->p.num_elements; LOG (GNUNET_ERROR_TYPE_DEBUG, "Execution time: Build %llu ms, LP %llu ms, MLP %llu ms\n", (unsigned long long) duration_build.rel_value, diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index d80736124..235b7d14d 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -39,8 +39,8 @@ #define MLP_AVERAGING_QUEUE_LENGTH 3 -#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) -#define MLP_MAX_ITERATIONS 1024 +#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) +#define MLP_MAX_ITERATIONS 4096 #define DEFAULT_D 1.0 #define DEFAULT_R 1.0 @@ -61,7 +61,17 @@ struct MLP_Solution struct GNUNET_TIME_Relative mip_dur; int lp_res; + int lp_presolv; int mip_res; + int mip_presolv; + + int p_elements; + int p_cols; + int p_rows; + + int n_peers; + int n_addresses; + }; struct ATS_Peer diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index 4769842c8..c615a57b9 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c @@ -126,12 +126,6 @@ end_now (int res) ret = res; } -static void -end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - -} - static void bandwidth_changed_cb (void *cls, struct ATS_Address *address) @@ -237,11 +231,16 @@ check (void *cls, char *const *args, const char *cfgfile, { GAS_mlp_solve_problem (mlp, addresses); - fprintf (stderr, "Solving problem for %u peers with each %u addresses (build/LP/MIP in ms): %llu %llu %llu\n", + fprintf (stderr, "%u peers each %u addresses; state [%s/%s], (build/LP/MIP in ms): %04llu %04llu %04llu; presolv LP/MIP [%s/%s]; size (cols x rows, nonzero elements): [%u x %u] = %u\n", cp + 1, ca, + (GNUNET_OK == mlp->ps.lp_res) ? "OK" : "FAIL", + (GNUNET_OK == mlp->ps.mip_res) ? "OK" : "FAIL", (unsigned long long) mlp->ps.build_dur.rel_value, (unsigned long long) mlp->ps.lp_dur.rel_value, - (unsigned long long) mlp->ps.mip_dur.rel_value); + (unsigned long long) mlp->ps.mip_dur.rel_value, + (GLP_YES == mlp->ps.lp_presolv) ? "YES" : "NO", + (GNUNET_OK == mlp->ps.mip_presolv) ? "YES" : "NO", + mlp->ps.p_cols, mlp->ps.p_rows, mlp->ps.p_elements); } } @@ -287,7 +286,6 @@ main (int argc, char *argv[]) if (0 != atoi(argv[c+1])) { N_peers_start = atoi(argv[c+1]); - fprintf (stderr, "peers_start: %u\n",N_peers_start ); } } if ((0 == strcmp (argv[c], "-w")) && (c < argc)) @@ -295,7 +293,6 @@ main (int argc, char *argv[]) if (0 != atoi(argv[c+1])) { N_peers_end = atoi(argv[c+1]); - fprintf (stderr, "peers_end: %u\n",N_peers_end ); } } if ((0 == strcmp (argv[c], "-a")) && (c < argc)) @@ -303,7 +300,6 @@ main (int argc, char *argv[]) if (0 != atoi(argv[c+1])) { N_address = atoi(argv[c+1]); - fprintf (stderr, "address: %u\n",N_address ); } } }