aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-17 17:35:17 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-17 17:35:17 +0000
commit25d61fa518975bac68f40268853740da33b98e67 (patch)
treea8b066aa3878240acef682f0fa14adc0309e037a /src/ats
parent9dbc6c02ceb87b56baf0e84133ec50064b3ef20b (diff)
downloadgnunet-25d61fa518975bac68f40268853740da33b98e67.tar.gz
gnunet-25d61fa518975bac68f40268853740da33b98e67.zip
- hunting a bug
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c20
-rw-r--r--src/ats/perf_ats_mlp.c101
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:
877 mlp->lp_solved++; 877 mlp->lp_solved++;
878 mlp->lp_total_duration =+ duration.rel_value; 878 mlp->lp_total_duration =+ duration.rel_value;
879 s_ctx->lp_duration = duration; 879 s_ctx->lp_duration = duration;
880 880GNUNET_assert (mlp->stats!= NULL);
881 GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO); 881 GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO);
882 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO); 882 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO);
883 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)", 883 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)",
884 mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO); 884 mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO);
885 885
886 886 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
887 "ats-mlp",
888 "%llu %llu \n", duration.rel_value, mlp->lp_total_duration / mlp->lp_solved);
887 /* Analyze problem status */ 889 /* Analyze problem status */
888 res = glp_get_status (mlp->prob); 890 res = glp_get_status (mlp->prob);
889 switch (res) { 891 switch (res) {
@@ -960,7 +962,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
960 GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO); 962 GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO);
961 GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average (ms)", 963 GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average (ms)",
962 mlp->mlp_total_duration / mlp->mlp_solved, GNUNET_NO); 964 mlp->mlp_total_duration / mlp->mlp_solved, GNUNET_NO);
963 965GNUNET_break(0);
964 /* Analyze problem status */ 966 /* Analyze problem status */
965 res = glp_mip_status(mlp->prob); 967 res = glp_mip_status(mlp->prob);
966 switch (res) { 968 switch (res) {
@@ -1027,7 +1029,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
1027 res = mlp_solve_lp_problem (mlp, &s_ctx); 1029 res = mlp_solve_lp_problem (mlp, &s_ctx);
1028 if (res != GNUNET_OK) 1030 if (res != GNUNET_OK)
1029 { 1031 {
1030 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n"); 1032 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n");
1031 return GNUNET_SYSERR; 1033 return GNUNET_SYSERR;
1032 } 1034 }
1033#if WRITE_MLP 1035#if WRITE_MLP
@@ -1041,7 +1043,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
1041 res = mlp_solve_mlp_problem (mlp, &s_ctx); 1043 res = mlp_solve_mlp_problem (mlp, &s_ctx);
1042 if (res != GNUNET_OK) 1044 if (res != GNUNET_OK)
1043 { 1045 {
1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n"); 1046 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n");
1045 return GNUNET_SYSERR; 1047 return GNUNET_SYSERR;
1046 } 1048 }
1047#if WRITE_MLP 1049#if WRITE_MLP
@@ -1119,7 +1121,13 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1119 char * quota_in_str; 1121 char * quota_in_str;
1120 1122
1121 /* Init GLPK environment */ 1123 /* Init GLPK environment */
1122 GNUNET_assert (glp_init_env() == 0); 1124 int res = 0;
1125 if (0 != (res = glp_init_env()))
1126 {
1127 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK %u\n", res);
1128 GNUNET_free(mlp);
1129 return NULL;
1130 }
1123 1131
1124 /* Create initial MLP problem */ 1132 /* Create initial MLP problem */
1125 mlp->prob = glp_create_prob(); 1133 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,
84 const struct GNUNET_SCHEDULER_TaskContext *tc) 84 const struct GNUNET_SCHEDULER_TaskContext *tc)
85{ 85{
86 unsigned int ca; 86 unsigned int ca;
87 for (ca=0; ca < (peers * addresses); ca++) 87 if (NULL != a)
88 { 88 {
89 GNUNET_free (a[ca].plugin); 89 for (ca=0; ca < (peers * addresses); ca++)
90 GNUNET_free (a[ca].ats); 90 {
91 GNUNET_free (a[ca].plugin);
92 GNUNET_free (a[ca].ats);
93 }
91 } 94 }
92 GNUNET_CONTAINER_multihashmap_destroy(amap); 95 if (NULL != mlp)
93 GNUNET_free (a); 96 GAS_mlp_done (mlp);
94 GNUNET_free (p); 97
95 GNUNET_STATISTICS_destroy(stats,GNUNET_NO); 98 if (NULL != amap)
99 GNUNET_CONTAINER_multihashmap_destroy(amap);
100 GNUNET_free_non_null (a);
101 GNUNET_free_non_null (p);
102 if (stats != NULL)
103 GNUNET_STATISTICS_destroy (stats,GNUNET_NO);
96 104
97 if (NULL != stats_proc) 105 if (NULL != stats_proc)
98 { 106 {
@@ -103,13 +111,13 @@ do_shutdown (void *cls,
103 GNUNET_OS_process_close (stats_proc); 111 GNUNET_OS_process_close (stats_proc);
104 stats_proc = NULL; 112 stats_proc = NULL;
105 } 113 }
106 ret = 0;
107} 114}
108 115
109int stat_it (void *cls, const char *subsystem, 116int stat_lp_it (void *cls, const char *subsystem,
110 const char *name, uint64_t value, 117 const char *name, uint64_t value,
111 int is_persistent) 118 int is_persistent)
112{ 119{
120 GNUNET_break (0);
113 static int calls; 121 static int calls;
114 static long long unsigned lp_time; 122 static long long unsigned lp_time;
115 static long long unsigned mlp_time; 123 static long long unsigned mlp_time;
@@ -119,6 +127,7 @@ int stat_it (void *cls, const char *subsystem,
119 if (0 == strcmp (name, "# MLP execution time (ms)")) 127 if (0 == strcmp (name, "# MLP execution time (ms)"))
120 mlp_time = value; 128 mlp_time = value;
121 129
130 GNUNET_break (0);
122 calls ++; 131 calls ++;
123 132
124 if (2 == calls) 133 if (2 == calls)
@@ -131,31 +140,33 @@ int stat_it (void *cls, const char *subsystem,
131 return GNUNET_OK; 140 return GNUNET_OK;
132} 141}
133 142
134static void 143int stat_ready_it (void *cls, const char *subsystem,
135check (void *cls, char *const *args, const char *cfgfile, 144 const char *name, uint64_t value,
136 const struct GNUNET_CONFIGURATION_Handle *cfg) 145 int is_persistent)
137{ 146{
138#if !HAVE_LIBGLPK
139 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
140 ret = 1;
141 return;
142#endif
143 unsigned int c = 0; 147 unsigned int c = 0;
144 unsigned int c2 = 0; 148 unsigned int c2 = 0;
145 unsigned int ca = 0; 149 unsigned int ca = 0;
150 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
146 151
147 stats_proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics", 152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Statistics service ready\n");
148 "gnunet-service-statistics", NULL);
149 153
150 if (NULL == stats_proc) 154 GNUNET_STATISTICS_watch (stats, "ats", "# LP execution time (ms)", &stat_lp_it, NULL);
155 GNUNET_STATISTICS_watch (stats, "ats", "# MLP execution time (ms)", &stat_lp_it, NULL);
156
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
158
159 mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
160 if (NULL == mlp)
151 { 161 {
152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start statistics service \n"); 162 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init MLP\n");
153 ret = 1; 163 ret = 1;
154 return; 164 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
165 GNUNET_SCHEDULER_cancel(shutdown_task);
166 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
167 return GNUNET_NO;
155 } 168 }
156 169
157 shutdown_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_HOURS, &do_shutdown, NULL);
158
159 if (peers == 0) 170 if (peers == 0)
160 peers = DEF_PEERS; 171 peers = DEF_PEERS;
161 if (addresses == 0) 172 if (addresses == 0)
@@ -164,13 +175,8 @@ check (void *cls, char *const *args, const char *cfgfile,
164 p = GNUNET_malloc (peers * sizeof (struct ATS_Peer)); 175 p = GNUNET_malloc (peers * sizeof (struct ATS_Peer));
165 a = GNUNET_malloc (peers * addresses * sizeof (struct ATS_Address)); 176 a = GNUNET_malloc (peers * addresses * sizeof (struct ATS_Address));
166 177
167 stats = GNUNET_STATISTICS_create("ats", cfg);
168
169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
170
171 amap = GNUNET_CONTAINER_multihashmap_create(addresses * peers); 178 amap = GNUNET_CONTAINER_multihashmap_create(addresses * peers);
172 179
173 mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
174 mlp->auto_solve = GNUNET_NO; 180 mlp->auto_solve = GNUNET_NO;
175 for (c=0; c < peers; c++) 181 for (c=0; c < peers; c++)
176 { 182 {
@@ -209,14 +215,43 @@ check (void *cls, char *const *args, const char *cfgfile,
209 215
210 /* Solving the problem */ 216 /* Solving the problem */
211 if (GNUNET_OK == GAS_mlp_solve_problem(mlp)) 217 if (GNUNET_OK == GAS_mlp_solve_problem(mlp))
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n"); 218 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully \n");
213 else 219 else
214 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses); 220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses);
215 221
216 GAS_mlp_done (mlp); 222 GNUNET_log ( GNUNET_ERROR_TYPE_WARNING, "Waiting for statistics\n");
223
224
225 return GNUNET_OK;
226}
227
228static void
229check (void *cls, char *const *args, const char *cfgfile,
230 const struct GNUNET_CONFIGURATION_Handle *cfg)
231{
232#if !HAVE_LIBGLPK
233 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
234 ret = 1;
235 return;
236#endif
237
238 stats_proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
239 "gnunet-service-statistics", NULL);
240
241 if (NULL == stats_proc)
242 {
243 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start statistics service \n");
244 ret = 1;
245 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
246 GNUNET_SCHEDULER_cancel(shutdown_task);
247 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
248 return;
249 }
250
251 stats = GNUNET_STATISTICS_create("ats", cfg);
217 252
218 GNUNET_STATISTICS_get (stats, "ats", "# LP execution time (ms)", GNUNET_TIME_UNIT_MINUTES, NULL, &stat_it, NULL); 253 GNUNET_STATISTICS_watch (stats, "ats", "watch", &stat_ready_it, (void *) cfg);
219 GNUNET_STATISTICS_get (stats, "ats", "# MLP execution time (ms)", GNUNET_TIME_UNIT_MINUTES, NULL, &stat_it, NULL); 254 GNUNET_STATISTICS_set(stats, "watch", 1, GNUNET_NO);
220 return; 255 return;
221} 256}
222 257