[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21013 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21013 - gnunet/src/ats |
Date: |
Wed, 18 Apr 2012 17:49:57 +0200 |
Author: wachs
Date: 2012-04-18 17:49:57 +0200 (Wed, 18 Apr 2012)
New Revision: 21013
Modified:
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
gnunet/src/ats/perf_ats_mlp.c
Log:
- remove statistics use return values
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-04-18 14:21:25 UTC
(rev 21012)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-04-18 15:49:57 UTC
(rev 21013)
@@ -807,13 +807,6 @@
}
-struct SolveContext
-{
- struct GNUNET_TIME_Relative lp_duration;
- struct GNUNET_TIME_Relative mlp_duration;
-};
-
-
/**
* Solves the LP problem
*
@@ -822,7 +815,7 @@
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
static int
-mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
+mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct
GAS_MLP_SolutionContext *s_ctx)
{
int res;
struct GNUNET_TIME_Relative duration;
@@ -916,7 +909,7 @@
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
int
-mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
+mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct
GAS_MLP_SolutionContext *s_ctx)
{
int res;
struct GNUNET_TIME_Relative duration;
@@ -981,23 +974,23 @@
return GNUNET_OK;
}
-int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp);
+int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct
GAS_MLP_SolutionContext *ctx);
static void
mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GAS_MLP_Handle *mlp = cls;
+ struct GAS_MLP_SolutionContext ctx;
mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n");
if (mlp->addr_in_problem != 0)
- GAS_mlp_solve_problem(mlp);
+ GAS_mlp_solve_problem(mlp, &ctx);
}
/**
@@ -1007,12 +1000,16 @@
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
int
-GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
+GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct
GAS_MLP_SolutionContext *ctx)
{
int res;
- struct SolveContext s_ctx;
mlp->last_execution = GNUNET_TIME_absolute_get ();
+ ctx->lp_result = GNUNET_SYSERR;
+ ctx->mlp_result = GNUNET_SYSERR;
+ ctx->lp_duration = GNUNET_TIME_relative_get_forever();
+ ctx->mlp_duration = GNUNET_TIME_relative_get_forever();
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n");
#if WRITE_MLP
char * name;
@@ -1023,12 +1020,14 @@
GNUNET_free (name);
# endif
- res = mlp_solve_lp_problem (mlp, &s_ctx);
+ res = mlp_solve_lp_problem (mlp, ctx);
+ ctx->lp_result = res;
if (res != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "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);
@@ -1037,7 +1036,8 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n");
- res = mlp_solve_mlp_problem (mlp, &s_ctx);
+ res = mlp_solve_mlp_problem (mlp, ctx);
+ ctx->mlp_result = res;
if (res != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n");
@@ -1050,7 +1050,7 @@
# endif
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);
+ (GNUNET_OK == res) ? "successfully" : "failed",
ctx->lp_duration.rel_value, ctx->mlp_duration.rel_value);
/* Process result */
struct ATS_Peer *p = NULL;
struct ATS_Address *a = NULL;
@@ -1085,7 +1085,7 @@
GNUNET_SCHEDULER_cancel(mlp->mlp_task);
mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
}
- mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval,
&mlp_scheduler, mlp);
+ //mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval,
&mlp_scheduler, mlp);
return res;
}
@@ -1427,7 +1427,7 @@
c3 ++;
}
}
- if (c3 > 0)
+ if ((c3 > 0) && (avg > 0))
/* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/
mlpi->q_averaged[c] = (double) c3 / avg;
else
@@ -1452,7 +1452,7 @@
c3 ++;
}
}
- if (c3 > 0)
+ if ((c3 > 0) && (avg > 0))
/* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/
mlpi->q_averaged[c] = (double) c3 / avg;
else
@@ -1540,6 +1540,7 @@
{
int new;
struct MLP_information *mlpi;
+ struct GAS_MLP_SolutionContext ctx;
GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO);
@@ -1624,7 +1625,7 @@
mlp->presolver_required = GNUNET_YES;
}
if (mlp->auto_solve == GNUNET_YES)
- GAS_mlp_solve_problem (mlp);
+ GAS_mlp_solve_problem (mlp, &ctx);
}
/**
@@ -1641,6 +1642,7 @@
GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct
GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address)
{
GNUNET_STATISTICS_update (mlp->stats,"# LP address deletions", 1, GNUNET_NO);
+ struct GAS_MLP_SolutionContext ctx;
/* Free resources */
if (address->mlp_information != NULL)
@@ -1682,7 +1684,7 @@
/* Recalculate */
mlp->presolver_required = GNUNET_YES;
if (mlp->auto_solve == GNUNET_YES)
- GAS_mlp_solve_problem (mlp);
+ GAS_mlp_solve_problem (mlp, &ctx);
}
}
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-04-18 14:21:25 UTC
(rev 21012)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-04-18 15:49:57 UTC
(rev 21013)
@@ -73,6 +73,14 @@
struct ATS_Address *address;
};
+struct GAS_MLP_SolutionContext
+{
+ int lp_result;
+ int mlp_result;
+ struct GNUNET_TIME_Relative lp_duration;
+ struct GNUNET_TIME_Relative mlp_duration;
+};
+
/**
* MLP Handle
*/
@@ -324,7 +332,7 @@
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
int
-GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp);
+GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct
GAS_MLP_SolutionContext *ctx);
/**
Modified: gnunet/src/ats/perf_ats_mlp.c
===================================================================
--- gnunet/src/ats/perf_ats_mlp.c 2012-04-18 14:21:25 UTC (rev 21012)
+++ gnunet/src/ats/perf_ats_mlp.c 2012-04-18 15:49:57 UTC (rev 21013)
@@ -47,16 +47,13 @@
static int ret;
-struct GNUNET_STATISTICS_Handle * stats;
-
struct GNUNET_CONTAINER_MultiHashMap * amap;
struct GAS_MLP_Handle *mlp;
-struct GNUNET_STATISTICS_Handle * stats;
-struct GNUNET_OS_Process *stats_proc;
+
GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
struct PeerContext
@@ -107,70 +104,27 @@
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)
- {
- if (0 != GNUNET_OS_process_kill (stats_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait (stats_proc) != GNUNET_OK)
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
- GNUNET_OS_process_close (stats_proc);
- stats_proc = NULL;
- }
}
-int stat_lp_it (void *cls, const char *subsystem,
- const char *name, uint64_t value,
- int is_persistent)
-{
- static long long unsigned lp_time;
- static long long unsigned mlp_time;
- static long long unsigned lp_time_set;
- static long long unsigned mlp_time_set;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received: `%s' : %u \n", name, value);
-
- if (0 == strcmp (name, "# LP execution time (ms)"))
- {
- lp_time = value;
- lp_time_set = GNUNET_YES;
- }
- if (0 == strcmp (name, "# MLP execution time (ms)"))
- {
- mlp_time = value;
- mlp_time_set = GNUNET_YES;
- }
-
- if ((GNUNET_YES == lp_time_set) && (GNUNET_YES == mlp_time_set))
- {
- if (GNUNET_YES == numeric)
- printf ("%u;%u;%llu;%llu\n",peers, addresses, lp_time, mlp_time);
- if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
- GNUNET_SCHEDULER_cancel(shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL);
- }
- return GNUNET_OK;
-}
-
-int stat_ready_it (void *cls, const char *subsystem,
- const char *name, uint64_t value,
- int is_persistent)
+static void
+check (void *cls, char *const *args, const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
unsigned int c = 0;
unsigned int c2 = 0;
unsigned int ca = 0;
- struct GNUNET_CONFIGURATION_Handle *cfg = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Statistics service ready\n");
+#if !HAVE_LIBGLPK
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
+ ret = 1;
+ return;
+#endif
- 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);
+ mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
if (NULL == mlp)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init MLP\n");
@@ -178,7 +132,6 @@
if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
GNUNET_SCHEDULER_cancel(shutdown_task);
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return GNUNET_NO;
}
if (peers == 0)
@@ -195,7 +148,7 @@
for (c=0; c < peers; 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);
+ GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_NONCE,
&p[c].id.hashPubKey);
for (c2=0; c2 < addresses; c2++)
{
@@ -212,9 +165,9 @@
a[ca].ats = GNUNET_malloc (2 * sizeof (struct GNUNET_ATS_Information));
a[ca].ats[0].type = GNUNET_ATS_QUALITY_NET_DELAY;
- a[ca].ats[0].value = 20;
+ a[ca].ats[0].value =
GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10);
a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE;
- a[ca].ats[1].value = 2;
+ a[ca].ats[1].value =
GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2);
a[ca].ats_count = 2;
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);
@@ -222,51 +175,30 @@
ca++;
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem contains %u peers and %u
adresses\n", mlp->c_p, mlp->addr_in_problem);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u
adresses\n", mlp->c_p, mlp->addr_in_problem);
GNUNET_assert (peers == mlp->c_p);
GNUNET_assert (peers * addresses == mlp->addr_in_problem);
/* Solving the problem */
- if (GNUNET_OK == GAS_mlp_solve_problem(mlp))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u
addresses failed\n", peers, addresses);
+ struct GAS_MLP_SolutionContext ctx;
- 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)
+ if (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx))
{
- 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;
+ GNUNET_assert (GNUNET_OK == ctx.lp_result);
+ GNUNET_assert (GNUNET_OK == ctx.mlp_result);
+ if (GNUNET_YES == numeric)
+ printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem, (long long
unsigned int) ctx.lp_duration.rel_value, (long long unsigned int)
ctx.mlp_duration.rel_value);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully (LP:
%llu ms / MLP: %llu ms)\n", ctx.lp_duration.rel_value,
ctx.mlp_duration.rel_value);
+
}
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u
addresses failed\n", peers, addresses);
+ if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
+ GNUNET_SCHEDULER_cancel(shutdown_task);
+ shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- stats = GNUNET_STATISTICS_create("ats", cfg);
-
- GNUNET_STATISTICS_watch (stats, "ats", "watch", &stat_ready_it, (void *)
cfg);
- GNUNET_STATISTICS_set(stats, "watch", 1, GNUNET_NO);
- return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21013 - gnunet/src/ats,
gnunet <=