diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-05 16:22:58 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-05 16:22:58 +0000 |
commit | 119d6128a594bbc64442b9435dc7f1dbebaa7300 (patch) | |
tree | 455f397c62bdf0d66fe5b72b8680118de50b4c9b /src | |
parent | 3c468b850ea7412137e96a4bdfb20d1b502d4ed0 (diff) | |
download | gnunet-119d6128a594bbc64442b9435dc7f1dbebaa7300.tar.gz gnunet-119d6128a594bbc64442b9435dc7f1dbebaa7300.zip |
internal time logging
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/libgnunet_plugin_ats_mlp.c | 158 |
1 files changed, 94 insertions, 64 deletions
diff --git a/src/ats/libgnunet_plugin_ats_mlp.c b/src/ats/libgnunet_plugin_ats_mlp.c index 78a00f462..939e3aa83 100644 --- a/src/ats/libgnunet_plugin_ats_mlp.c +++ b/src/ats/libgnunet_plugin_ats_mlp.c | |||
@@ -1098,108 +1098,138 @@ GAS_mlp_solve_problem (void *solver) | |||
1098 | char *filename; | 1098 | char *filename; |
1099 | int res_lp = 0; | 1099 | int res_lp = 0; |
1100 | int res_mip = 0; | 1100 | int res_mip = 0; |
1101 | GNUNET_assert (NULL != solver); | 1101 | |
1102 | struct GNUNET_TIME_Absolute start; | ||
1103 | struct GNUNET_TIME_Relative dur_total; | ||
1104 | struct GNUNET_TIME_Relative dur_setup; | ||
1105 | struct GNUNET_TIME_Relative dur_lp; | ||
1106 | struct GNUNET_TIME_Relative dur_mlp; | ||
1107 | |||
1108 | GNUNET_assert(NULL != solver); | ||
1102 | 1109 | ||
1103 | if (GNUNET_YES == mlp->bulk_lock) | 1110 | if (GNUNET_YES == mlp->bulk_lock) |
1104 | { | 1111 | { |
1105 | mlp->bulk_request ++; | 1112 | mlp->bulk_request++; |
1106 | return GNUNET_NO; | 1113 | return GNUNET_NO; |
1107 | } | 1114 | } |
1108 | notify (mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS, | 1115 | notify(mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS, |
1109 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1116 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1117 | start = GNUNET_TIME_absolute_get(); | ||
1110 | 1118 | ||
1111 | if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers)) | 1119 | if (0 == GNUNET_CONTAINER_multipeermap_size(mlp->requested_peers)) |
1112 | { | 1120 | { |
1113 | notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE); | 1121 | notify(mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE); |
1114 | return GNUNET_OK; /* No pending requests */ | 1122 | return GNUNET_OK; /* No pending requests */ |
1115 | } | 1123 | } |
1116 | if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses)) | 1124 | if (0 == GNUNET_CONTAINER_multipeermap_size(mlp->addresses)) |
1117 | { | 1125 | { |
1118 | notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE); | 1126 | notify(mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE); |
1119 | return GNUNET_OK; /* No addresses available */ | 1127 | return GNUNET_OK; /* No addresses available */ |
1120 | } | 1128 | } |
1121 | 1129 | ||
1122 | if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) | 1130 | if ((GNUNET_NO == mlp->mlp_prob_changed) |
1123 | { | 1131 | && (GNUNET_NO == mlp->mlp_prob_updated)) |
1124 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n"); | 1132 | { |
1125 | notify (mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE); | 1133 | LOG(GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n"); |
1126 | return GNUNET_OK; | 1134 | notify(mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE); |
1127 | } | 1135 | return GNUNET_OK; |
1136 | } | ||
1128 | if (GNUNET_YES == mlp->mlp_prob_changed) | 1137 | if (GNUNET_YES == mlp->mlp_prob_changed) |
1129 | { | 1138 | { |
1130 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); | 1139 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); |
1131 | notify (mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_FULL); | 1140 | notify(mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_FULL); |
1132 | mlp_delete_problem (mlp); | 1141 | mlp_delete_problem(mlp); |
1133 | if (GNUNET_SYSERR == mlp_create_problem (mlp)) | 1142 | if (GNUNET_SYSERR == mlp_create_problem(mlp)) |
1134 | { | 1143 | { |
1135 | notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL, GAS_INFO_FULL); | 1144 | notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_FAIL, GAS_INFO_FULL); |
1136 | return GNUNET_SYSERR; | 1145 | return GNUNET_SYSERR; |
1137 | } | 1146 | } |
1138 | notify (mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL); | 1147 | notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL); |
1139 | mlp->control_param_lp.presolve = GLP_YES; | 1148 | mlp->control_param_lp.presolve = GLP_YES; |
1140 | mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ | 1149 | mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ |
1141 | } | 1150 | } |
1142 | else | 1151 | else |
1143 | { | 1152 | { |
1144 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem was updated, resolving\n"); | 1153 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Problem was updated, resolving\n"); |
1145 | } | 1154 | } |
1155 | |||
1156 | dur_setup = GNUNET_TIME_absolute_get_duration (start); | ||
1146 | 1157 | ||
1147 | /* Run LP solver */ | 1158 | /* Run LP solver */ |
1148 | 1159 | ||
1149 | notify (mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS, | 1160 | notify(mlp, GAS_OP_SOLVE_LP_START, GAS_STAT_SUCCESS, |
1150 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1161 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1151 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Running LP solver %s\n", | 1162 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1163 | "Running LP solver %s\n", | ||
1152 | (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver"); | 1164 | (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver"); |
1153 | res_lp = mlp_solve_lp_problem (mlp); | 1165 | res_lp = mlp_solve_lp_problem(mlp); |
1154 | notify (mlp, GAS_OP_SOLVE_LP_STOP, | 1166 | notify(mlp, GAS_OP_SOLVE_LP_STOP, |
1155 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1167 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1156 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1168 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1157 | 1169 | ||
1170 | dur_lp = GNUNET_TIME_absolute_get_duration (start); | ||
1171 | dur_lp = GNUNET_TIME_relative_subtract(dur_lp, dur_setup); | ||
1158 | 1172 | ||
1159 | /* Run MLP solver */ | 1173 | /* Run MLP solver */ |
1160 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n"); | 1174 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n"); |
1161 | notify (mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS, | 1175 | notify(mlp, GAS_OP_SOLVE_MLP_START, GAS_STAT_SUCCESS, |
1162 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1176 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1163 | res_mip = mlp_solve_mlp_problem (mlp); | 1177 | res_mip = mlp_solve_mlp_problem(mlp); |
1164 | notify (mlp, GAS_OP_SOLVE_MLP_STOP, | 1178 | notify(mlp, GAS_OP_SOLVE_MLP_STOP, |
1165 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1179 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1166 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1180 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1167 | notify (mlp, GAS_OP_SOLVE_STOP, | 1181 | notify(mlp, GAS_OP_SOLVE_STOP, |
1168 | (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1182 | (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1169 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1183 | (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1170 | 1184 | ||
1185 | dur_mlp = GNUNET_TIME_absolute_get_duration (start); | ||
1186 | dur_mlp = GNUNET_TIME_relative_subtract(dur_mlp, dur_setup); | ||
1187 | dur_mlp = GNUNET_TIME_relative_subtract(dur_mlp, dur_lp); | ||
1188 | dur_total = GNUNET_TIME_absolute_get_duration (start); | ||
1189 | |||
1190 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1191 | "Execution time for %s solve: (total/setup/lp/mlp) : %llu %llu %llu %llu\n", | ||
1192 | (GNUNET_YES == mlp->mlp_prob_changed) ? "full" : "updated", | ||
1193 | (unsigned long long) dur_total.rel_value_us, | ||
1194 | (unsigned long long) dur_setup.rel_value_us, | ||
1195 | (unsigned long long) dur_lp.rel_value_us, | ||
1196 | (unsigned long long) dur_mlp.rel_value_us); | ||
1197 | |||
1171 | /* Save stats */ | 1198 | /* Save stats */ |
1172 | mlp->ps.lp_res = res_lp; | 1199 | mlp->ps.lp_res = res_lp; |
1173 | mlp->ps.mip_res = res_mip; | 1200 | mlp->ps.mip_res = res_mip; |
1174 | mlp->ps.lp_presolv = mlp->control_param_lp.presolve; | 1201 | mlp->ps.lp_presolv = mlp->control_param_lp.presolve; |
1175 | mlp->ps.mip_presolv = mlp->control_param_mlp.presolve; | 1202 | mlp->ps.mip_presolv = mlp->control_param_mlp.presolve; |
1176 | mlp->ps.p_cols = glp_get_num_cols (mlp->p.prob); | 1203 | mlp->ps.p_cols = glp_get_num_cols(mlp->p.prob); |
1177 | mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob); | 1204 | mlp->ps.p_rows = glp_get_num_rows(mlp->p.prob); |
1178 | mlp->ps.p_elements = mlp->p.num_elements; | 1205 | mlp->ps.p_elements = mlp->p.num_elements; |
1179 | 1206 | ||
1180 | /* Propagate result*/ | 1207 | /* Propagate result*/ |
1181 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) | 1208 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) |
1182 | { | 1209 | { |
1183 | GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses, &mlp_propagate_results, mlp); | 1210 | GNUNET_CONTAINER_multipeermap_iterate(mlp->addresses, |
1184 | } | 1211 | &mlp_propagate_results, mlp); |
1212 | } | ||
1185 | 1213 | ||
1186 | struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); | 1214 | struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); |
1187 | if (GNUNET_YES == mlp->write_mip_mps) | 1215 | if (GNUNET_YES == mlp->write_mip_mps) |
1188 | { | 1216 | { |
1189 | /* Write problem to disk */ | 1217 | /* Write problem to disk */ |
1190 | GNUNET_asprintf (&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers, mlp->p.num_addresses, time.abs_value_us); | 1218 | GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers, |
1191 | LOG (GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename); | 1219 | mlp->p.num_addresses, time.abs_value_us); |
1192 | glp_write_lp(mlp->p.prob, NULL, filename); | 1220 | LOG(GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename); |
1193 | GNUNET_free (filename); | 1221 | glp_write_lp(mlp->p.prob, NULL, filename); |
1194 | } | 1222 | GNUNET_free(filename); |
1223 | } | ||
1195 | if (GNUNET_YES == mlp->write_mip_sol) | 1224 | if (GNUNET_YES == mlp->write_mip_sol) |
1196 | { | 1225 | { |
1197 | /* Write solution to disk */ | 1226 | /* Write solution to disk */ |
1198 | GNUNET_asprintf (&filename, "problem_p_%u_a%u_%llu.sol", mlp->p.num_peers, mlp->p.num_addresses, time.abs_value_us); | 1227 | GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.sol", mlp->p.num_peers, |
1199 | glp_print_mip (mlp->p.prob, filename ); | 1228 | mlp->p.num_addresses, time.abs_value_us); |
1200 | LOG (GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename); | 1229 | glp_print_mip(mlp->p.prob, filename); |
1201 | GNUNET_free (filename); | 1230 | LOG(GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename); |
1202 | } | 1231 | GNUNET_free(filename); |
1232 | } | ||
1203 | 1233 | ||
1204 | /* Reset change and update marker */ | 1234 | /* Reset change and update marker */ |
1205 | mlp->control_param_lp.presolve = GLP_NO; | 1235 | mlp->control_param_lp.presolve = GLP_NO; |