From 25d61fa518975bac68f40268853740da33b98e67 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 17 Apr 2012 17:35:17 +0000 Subject: [PATCH] - hunting a bug --- src/ats/gnunet-service-ats_addresses_mlp.c | 20 ++-- src/ats/perf_ats_mlp.c | 101 ++++++++++++++------- 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index e2d5afa9d..3c45ac43d 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -877,13 +877,15 @@ lp_solv: mlp->lp_solved++; mlp->lp_total_duration =+ duration.rel_value; s_ctx->lp_duration = duration; - +GNUNET_assert (mlp->stats!= NULL); 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); GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)", mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO); - + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, + "ats-mlp", + "%llu %llu \n", duration.rel_value, mlp->lp_total_duration / mlp->lp_solved); /* Analyze problem status */ res = glp_get_status (mlp->prob); switch (res) { @@ -960,7 +962,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx) GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO); GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average (ms)", mlp->mlp_total_duration / mlp->mlp_solved, GNUNET_NO); - +GNUNET_break(0); /* Analyze problem status */ res = glp_mip_status(mlp->prob); switch (res) { @@ -1027,7 +1029,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) res = mlp_solve_lp_problem (mlp, &s_ctx); if (res != GNUNET_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n"); return GNUNET_SYSERR; } #if WRITE_MLP @@ -1041,7 +1043,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) res = mlp_solve_mlp_problem (mlp, &s_ctx); if (res != GNUNET_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n"); return GNUNET_SYSERR; } #if WRITE_MLP @@ -1119,7 +1121,13 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, char * quota_in_str; /* Init GLPK environment */ - GNUNET_assert (glp_init_env() == 0); + int res = 0; + if (0 != (res = glp_init_env())) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK %u\n", res); + GNUNET_free(mlp); + return NULL; + } /* Create initial MLP problem */ mlp->prob = glp_create_prob(); diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index bf2de8719..24590e68a 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c @@ -84,15 +84,23 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { unsigned int ca; - for (ca=0; ca < (peers * addresses); ca++) + if (NULL != a) { - GNUNET_free (a[ca].plugin); - GNUNET_free (a[ca].ats); + for (ca=0; ca < (peers * addresses); ca++) + { + GNUNET_free (a[ca].plugin); + GNUNET_free (a[ca].ats); + } } - GNUNET_CONTAINER_multihashmap_destroy(amap); - GNUNET_free (a); - GNUNET_free (p); - GNUNET_STATISTICS_destroy(stats,GNUNET_NO); + if (NULL != mlp) + GAS_mlp_done (mlp); + + if (NULL != amap) + GNUNET_CONTAINER_multihashmap_destroy(amap); + GNUNET_free_non_null (a); + GNUNET_free_non_null (p); + if (stats != NULL) + GNUNET_STATISTICS_destroy (stats,GNUNET_NO); if (NULL != stats_proc) { @@ -103,13 +111,13 @@ do_shutdown (void *cls, GNUNET_OS_process_close (stats_proc); stats_proc = NULL; } - ret = 0; } -int stat_it (void *cls, const char *subsystem, +int stat_lp_it (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) { + GNUNET_break (0); static int calls; static long long unsigned lp_time; static long long unsigned mlp_time; @@ -119,6 +127,7 @@ int stat_it (void *cls, const char *subsystem, if (0 == strcmp (name, "# MLP execution time (ms)")) mlp_time = value; + GNUNET_break (0); calls ++; if (2 == calls) @@ -131,31 +140,33 @@ int stat_it (void *cls, const char *subsystem, return GNUNET_OK; } -static void -check (void *cls, char *const *args, const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *cfg) +int stat_ready_it (void *cls, const char *subsystem, + const char *name, uint64_t value, + int is_persistent) { -#if !HAVE_LIBGLPK - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); - ret = 1; - return; -#endif unsigned int c = 0; unsigned int c2 = 0; unsigned int ca = 0; + struct GNUNET_CONFIGURATION_Handle *cfg = cls; - stats_proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", NULL); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Statistics service ready\n"); - if (NULL == stats_proc) + GNUNET_STATISTICS_watch (stats, "ats", "# LP execution time (ms)", &stat_lp_it, NULL); + GNUNET_STATISTICS_watch (stats, "ats", "# MLP execution time (ms)", &stat_lp_it, NULL); + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses); + + mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); + if (NULL == mlp) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start statistics service \n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init MLP\n"); ret = 1; - return; + if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) + GNUNET_SCHEDULER_cancel(shutdown_task); + shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); + return GNUNET_NO; } - shutdown_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_HOURS, &do_shutdown, NULL); - if (peers == 0) peers = DEF_PEERS; if (addresses == 0) @@ -164,13 +175,8 @@ check (void *cls, char *const *args, const char *cfgfile, p = GNUNET_malloc (peers * sizeof (struct ATS_Peer)); a = GNUNET_malloc (peers * addresses * sizeof (struct ATS_Address)); - stats = GNUNET_STATISTICS_create("ats", cfg); - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses); - amap = GNUNET_CONTAINER_multihashmap_create(addresses * peers); - mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); mlp->auto_solve = GNUNET_NO; for (c=0; c < peers; c++) { @@ -209,14 +215,43 @@ check (void *cls, char *const *args, const char *cfgfile, /* Solving the problem */ if (GNUNET_OK == GAS_mlp_solve_problem(mlp)) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully \n"); else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses); - GAS_mlp_done (mlp); + GNUNET_log ( GNUNET_ERROR_TYPE_WARNING, "Waiting for statistics\n"); + + + return GNUNET_OK; +} + +static void +check (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ +#if !HAVE_LIBGLPK + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); + ret = 1; + return; +#endif + + stats_proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics", + "gnunet-service-statistics", NULL); + + if (NULL == stats_proc) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start statistics service \n"); + ret = 1; + if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) + GNUNET_SCHEDULER_cancel(shutdown_task); + shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); + return; + } + + stats = GNUNET_STATISTICS_create("ats", cfg); - GNUNET_STATISTICS_get (stats, "ats", "# LP execution time (ms)", GNUNET_TIME_UNIT_MINUTES, NULL, &stat_it, NULL); - GNUNET_STATISTICS_get (stats, "ats", "# MLP execution time (ms)", GNUNET_TIME_UNIT_MINUTES, NULL, &stat_it, NULL); + GNUNET_STATISTICS_watch (stats, "ats", "watch", &stat_ready_it, (void *) cfg); + GNUNET_STATISTICS_set(stats, "watch", 1, GNUNET_NO); return; } -- 2.25.1