aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ats/libgnunet_plugin_ats_mlp.c50
-rw-r--r--src/ats/perf_ats_solver.c56
-rw-r--r--src/include/gnunet_ats_plugin.h53
3 files changed, 133 insertions, 26 deletions
diff --git a/src/ats/libgnunet_plugin_ats_mlp.c b/src/ats/libgnunet_plugin_ats_mlp.c
index d6c59aff6..f45c5fe0b 100644
--- a/src/ats/libgnunet_plugin_ats_mlp.c
+++ b/src/ats/libgnunet_plugin_ats_mlp.c
@@ -1077,6 +1077,12 @@ mlp_propagate_results (void *cls,
1077 return GNUNET_OK; 1077 return GNUNET_OK;
1078} 1078}
1079 1079
1080static void notify (struct GAS_MLP_Handle *mlp,
1081 enum GAS_Solver_Operation op, enum GAS_Solver_Status stat)
1082{
1083 if (NULL != mlp->env->info_cb)
1084 mlp->env->info_cb (mlp->env->info_cb_cls, op, stat);
1085}
1080/** 1086/**
1081 * Solves the MLP problem 1087 * Solves the MLP problem
1082 * 1088 *
@@ -1090,12 +1096,6 @@ GAS_mlp_solve_problem (void *solver)
1090 char *filename; 1096 char *filename;
1091 int res_lp = 0; 1097 int res_lp = 0;
1092 int res_mip = 0; 1098 int res_mip = 0;
1093 struct GNUNET_TIME_Absolute start_build;
1094 struct GNUNET_TIME_Relative duration_build;
1095 struct GNUNET_TIME_Absolute start_lp;
1096 struct GNUNET_TIME_Relative duration_lp;
1097 struct GNUNET_TIME_Absolute start_mlp;
1098 struct GNUNET_TIME_Relative duration_mlp;
1099 GNUNET_assert (NULL != solver); 1099 GNUNET_assert (NULL != solver);
1100 1100
1101 if (GNUNET_YES == mlp->bulk_lock) 1101 if (GNUNET_YES == mlp->bulk_lock)
@@ -1103,71 +1103,69 @@ GAS_mlp_solve_problem (void *solver)
1103 mlp->bulk_request ++; 1103 mlp->bulk_request ++;
1104 return GNUNET_NO; 1104 return GNUNET_NO;
1105 } 1105 }
1106 notify (mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS);
1106 1107
1107 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers)) 1108 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers))
1109 {
1110 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS);
1108 return GNUNET_OK; /* No pending requests */ 1111 return GNUNET_OK; /* No pending requests */
1112 }
1109 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses)) 1113 if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses))
1114 {
1115 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS);
1110 return GNUNET_OK; /* No addresses available */ 1116 return GNUNET_OK; /* No addresses available */
1117 }
1111 1118
1112 if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) 1119 if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated))
1113 { 1120 {
1114 LOG (GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n"); 1121 LOG (GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n");
1122 notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS);
1115 return GNUNET_OK; 1123 return GNUNET_OK;
1116 } 1124 }
1117 if (GNUNET_YES == mlp->mlp_prob_changed) 1125 if (GNUNET_YES == mlp->mlp_prob_changed)
1118 { 1126 {
1119 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); 1127 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
1128 notify (mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS);
1120 mlp_delete_problem (mlp); 1129 mlp_delete_problem (mlp);
1121 start_build = GNUNET_TIME_absolute_get();
1122 if (GNUNET_SYSERR == mlp_create_problem (mlp)) 1130 if (GNUNET_SYSERR == mlp_create_problem (mlp))
1131 {
1132 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL);
1123 return GNUNET_SYSERR; 1133 return GNUNET_SYSERR;
1124 duration_build = GNUNET_TIME_absolute_get_duration (start_build); 1134 }
1135 notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS);
1125 mlp->control_param_lp.presolve = GLP_YES; 1136 mlp->control_param_lp.presolve = GLP_YES;
1126 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ 1137 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */
1127 } 1138 }
1128 else 1139 else
1129 { 1140 {
1130 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem was updated, resolving\n"); 1141 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem was updated, resolving\n");
1131 duration_build.rel_value_us = 0;
1132 } 1142 }
1133 1143
1134 /* Run LP solver */ 1144 /* Run LP solver */
1135 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n", 1145 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n",
1136 (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver"); 1146 (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver");
1137 start_lp = GNUNET_TIME_absolute_get(); 1147 notify (mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS);
1138 res_lp = mlp_solve_lp_problem (mlp); 1148 res_lp = mlp_solve_lp_problem (mlp);
1139 duration_lp = GNUNET_TIME_absolute_get_duration (start_lp); 1149 notify (mlp, GAS_OP_SOLVE_LP_STOP, (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL);
1140 1150
1141 1151
1142 /* Run MLP solver */ 1152 /* Run MLP solver */
1143 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n"); 1153 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n");
1144 start_mlp = GNUNET_TIME_absolute_get(); 1154 notify (mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS);
1145 res_mip = mlp_solve_mlp_problem (mlp); 1155 res_mip = mlp_solve_mlp_problem (mlp);
1156 notify (mlp, GAS_OP_SOLVE_MLP_STOP, (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL);
1146 1157
1147 duration_mlp = GNUNET_TIME_absolute_get_duration (start_mlp); 1158 notify (mlp, GAS_OP_SOLVE_STOP, (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL);
1148 1159
1149 /* Save stats */ 1160 /* Save stats */
1150 mlp->ps.lp_res = res_lp; 1161 mlp->ps.lp_res = res_lp;
1151 mlp->ps.mip_res = res_mip; 1162 mlp->ps.mip_res = res_mip;
1152 mlp->ps.build_dur = duration_build;
1153 mlp->ps.lp_dur = duration_lp;
1154 mlp->ps.mip_dur = duration_mlp;
1155 mlp->ps.lp_presolv = mlp->control_param_lp.presolve; 1163 mlp->ps.lp_presolv = mlp->control_param_lp.presolve;
1156 mlp->ps.mip_presolv = mlp->control_param_mlp.presolve; 1164 mlp->ps.mip_presolv = mlp->control_param_mlp.presolve;
1157 mlp->ps.p_cols = glp_get_num_cols (mlp->p.prob); 1165 mlp->ps.p_cols = glp_get_num_cols (mlp->p.prob);
1158 mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob); 1166 mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob);
1159 mlp->ps.p_elements = mlp->p.num_elements; 1167 mlp->ps.p_elements = mlp->p.num_elements;
1160 1168
1161 LOG (GNUNET_ERROR_TYPE_DEBUG,
1162 "Execution time: Build %s\n",
1163 GNUNET_STRINGS_relative_time_to_string (duration_build, GNUNET_NO));
1164 LOG (GNUNET_ERROR_TYPE_DEBUG,
1165 "Execution time: LP %s\n",
1166 GNUNET_STRINGS_relative_time_to_string (duration_lp, GNUNET_NO));
1167 LOG (GNUNET_ERROR_TYPE_DEBUG,
1168 "Execution time: MLP %s\n",
1169 GNUNET_STRINGS_relative_time_to_string (duration_mlp, GNUNET_NO));
1170
1171 /* Propagate result*/ 1169 /* Propagate result*/
1172 if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) 1170 if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip))
1173 { 1171 {
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index 5a229756b..f2762baba 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -64,6 +64,9 @@ struct PerfHandle
64 int opt_update_percent; 64 int opt_update_percent;
65 int opt_update_quantity; 65 int opt_update_quantity;
66 66
67 /**
68 * Is a bulk operation running?
69 */
67 int bulk_running; 70 int bulk_running;
68 71
69 char *ats_string; 72 char *ats_string;
@@ -308,6 +311,56 @@ perf_create_address (int cp, int ca)
308} 311}
309 312
310static void 313static void
314solver_info_cb (void *cls,
315 enum GAS_Solver_Operation op, enum GAS_Solver_Status stat)
316{
317 switch (op) {
318 case GAS_OP_SOLVE_START:
319 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
320 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_START",
321 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
322 break;
323 case GAS_OP_SOLVE_STOP:
324 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
325 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
326 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
327 break;
328 case GAS_OP_SOLVE_SETUP_START:
329 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
330 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
331 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
332 break;
333 case GAS_OP_SOLVE_SETUP_STOP:
334 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
335 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
336 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
337 break;
338 case GAS_OP_SOLVE_LP_START:
339 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
340 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
341 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
342 break;
343 case GAS_OP_SOLVE_LP_STOP:
344 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
345 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
346 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
347 break;
348 case GAS_OP_SOLVE_MLP_START:
349 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
350 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
351 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
352 break;
353 case GAS_OP_SOLVE_MLP_STOP:
354 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
355 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
356 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
357 break;
358 default:
359 break;
360 }
361}
362
363static void
311perf_run () 364perf_run ()
312{ 365{
313 struct ATS_Address *cur; 366 struct ATS_Address *cur;
@@ -514,6 +567,9 @@ run (void *cls, char * const *args, const char *cfgfile,
514 ph.env.get_preferences = &get_preferences_cb; 567 ph.env.get_preferences = &get_preferences_cb;
515 ph.env.get_property = &get_property_cb; 568 ph.env.get_property = &get_property_cb;
516 ph.env.network_count = GNUNET_ATS_NetworkTypeCount; 569 ph.env.network_count = GNUNET_ATS_NetworkTypeCount;
570 ph.env.info_cb = &solver_info_cb;
571 ph.env.info_cb_cls = NULL;
572
517 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; 573 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
518 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 574 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
519 { 575 {
diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h
index 29e169285..4e4a7e2b3 100644
--- a/src/include/gnunet_ats_plugin.h
+++ b/src/include/gnunet_ats_plugin.h
@@ -296,6 +296,47 @@ struct GNUNET_ATS_SolverFunctions
296 296
297 297
298/** 298/**
299 * Operation codes for solver information callback
300 */
301enum GAS_Solver_Operation
302{
303 GAS_OP_SOLVE_START,
304 GAS_OP_SOLVE_STOP,
305 GAS_OP_SOLVE_SETUP_START,
306 GAS_OP_SOLVE_SETUP_STOP,
307 GAS_OP_SOLVE_LP_START,
308 GAS_OP_SOLVE_LP_STOP,
309 GAS_OP_SOLVE_MLP_START,
310 GAS_OP_SOLVE_MLP_STOP
311};
312
313
314/**
315 * Status of the operation
316 */
317enum GAS_Solver_Status
318{
319 GAS_STAT_SUCCESS,
320 GAS_STAT_FAIL
321};
322
323/**
324 * Callback to call with additional information
325 * Used for measurement
326 *
327 * @param cls the closure
328 * @param op the operation
329 * @param peer the peer id
330 * @param kind the preference kind to change
331 * @param score the new preference score
332 * @param pref_rel the normalized preference value for this kind over all clients
333 */
334typedef void
335(*GAS_solver_information_callback) (void *cls,
336 enum GAS_Solver_Operation op, enum GAS_Solver_Status stat);
337
338
339/**
299 * Callback to call from solver when bandwidth for address has changed 340 * Callback to call from solver when bandwidth for address has changed
300 * 341 *
301 * @param address the with changed bandwidth assigned 342 * @param address the with changed bandwidth assigned
@@ -390,6 +431,18 @@ struct GNUNET_ATS_PluginEnvironment
390 431
391 432
392 /** 433 /**
434 * Callback for solver to call with status information,
435 * can be NULL
436 */
437 GAS_solver_information_callback info_cb;
438
439 /**
440 * Closure for information callback,
441 * can be NULL
442 */
443 void *info_cb_cls;
444
445 /**
393 * The ATS solver plugin functions to call 446 * The ATS solver plugin functions to call
394 */ 447 */
395 struct GNUNET_ATS_SolverFunctions sf; 448 struct GNUNET_ATS_SolverFunctions sf;