aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-02-26 15:07:40 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-02-26 15:07:40 +0000
commit9c27f52e1ccb192b84a5305eb10d9f159a6f26c6 (patch)
treeba16974ca8617dcb1b96983bd25c7fdfeb8fe422 /src
parentffb83798933660d0d5106193e1f6d55fb7c9a3fe (diff)
downloadgnunet-9c27f52e1ccb192b84a5305eb10d9f159a6f26c6.tar.gz
gnunet-9c27f52e1ccb192b84a5305eb10d9f159a6f26c6.zip
performance analysis
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c42
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h14
-rw-r--r--src/ats/perf_ats_mlp.c18
3 files changed, 40 insertions, 34 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index fc1bdf2e0..955a9cedd 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -895,14 +895,17 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
895 /* last +1 caused by glpk index starting with one: [1..elements]*/ 895 /* last +1 caused by glpk index starting with one: [1..elements]*/
896 p->ci = 1; 896 p->ci = 1;
897 /* row index */ 897 /* row index */
898 int *ia = GNUNET_malloc (p->num_elements * sizeof (int)); 898 p->ia = GNUNET_malloc (p->num_elements * sizeof (int));
899 p->ia = ia;
900 /* column index */ 899 /* column index */
901 int *ja = GNUNET_malloc (p->num_elements * sizeof (int)); 900 p->ja = GNUNET_malloc (p->num_elements * sizeof (int));
902 p->ja = ja;
903 /* coefficient */ 901 /* coefficient */
904 double *ar= GNUNET_malloc (p->num_elements * sizeof (double)); 902 p->ar = GNUNET_malloc (p->num_elements * sizeof (double));
905 p->ar = ar; 903
904 if ((NULL == p->ia) || (NULL == p->ja) || (NULL == p->ar))
905 {
906 LOG (GNUNET_ERROR_TYPE_ERROR, _("Problem size too large, cannot allocate memory!\n"));
907 return GNUNET_SYSERR;
908 }
906 909
907 /* Adding invariant columns */ 910 /* Adding invariant columns */
908 mlp_create_problem_add_invariant_columns (mlp, p); 911 mlp_create_problem_add_invariant_columns (mlp, p);
@@ -930,22 +933,12 @@ static int
930mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) 933mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp)
931{ 934{
932 int res = 0; 935 int res = 0;
933 if (GNUNET_YES == mlp->mlp_prob_changed)
934 {
935 /* Problem was recreated: use LP presolver */
936 mlp->control_param_lp.presolve = GLP_ON;
937 }
938 else
939 {
940 /* Problem was not recreated: do not use LP presolver */
941 mlp->control_param_lp.presolve = GLP_OFF;
942 }
943 936
944 res = glp_simplex(mlp->p.prob, &mlp->control_param_lp); 937 res = glp_simplex(mlp->p.prob, &mlp->control_param_lp);
945 if (0 == res) 938 if (0 == res)
946 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem: 0x%02X %s\n", res, mlp_solve_to_string(res)); 939 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem: 0x%02X %s\n", res, mlp_solve_to_string(res));
947 else 940 else
948 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res)); 941 LOG (GNUNET_ERROR_TYPE_WARNING, "Solving LP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res));
949 942
950 /* Analyze problem status */ 943 /* Analyze problem status */
951 res = glp_get_status (mlp->p.prob); 944 res = glp_get_status (mlp->p.prob);
@@ -959,7 +952,7 @@ mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp)
959 return GNUNET_OK; 952 return GNUNET_OK;
960 /* Problem was ill-defined, no way to handle that */ 953 /* Problem was ill-defined, no way to handle that */
961 default: 954 default:
962 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem failed, no solution: 0x%02X %s\n", 955 LOG (GNUNET_ERROR_TYPE_WARNING, "Solving LP problem failed, no solution: 0x%02X %s\n",
963 res, mlp_status_to_string(res)); 956 res, mlp_status_to_string(res));
964 return GNUNET_SYSERR; 957 return GNUNET_SYSERR;
965 } 958 }
@@ -980,7 +973,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
980 if (0 == res) 973 if (0 == res)
981 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem: 0x%02X %s\n", res, mlp_solve_to_string(res)); 974 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem: 0x%02X %s\n", res, mlp_solve_to_string(res));
982 else 975 else
983 LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res)); 976 LOG (GNUNET_ERROR_TYPE_WARNING, "Solving MLP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res));
984 /* Analyze problem status */ 977 /* Analyze problem status */
985 res = glp_mip_status(mlp->p.prob); 978 res = glp_mip_status(mlp->p.prob);
986 switch (res) { 979 switch (res) {
@@ -992,7 +985,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
992 return GNUNET_OK; 985 return GNUNET_OK;
993 /* Problem was ill-defined, no way to handle that */ 986 /* Problem was ill-defined, no way to handle that */
994 default: 987 default:
995 LOG (GNUNET_ERROR_TYPE_DEBUG,"Solving MLP problem failed, 0x%02X %s\n\n", res, mlp_status_to_string(res)); 988 LOG (GNUNET_ERROR_TYPE_WARNING,"Solving MLP problem failed, 0x%02X %s\n\n", res, mlp_status_to_string(res));
996 return GNUNET_SYSERR; 989 return GNUNET_SYSERR;
997 } 990 }
998} 991}
@@ -1092,9 +1085,11 @@ GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addr
1092 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n"); 1085 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
1093 mlp_delete_problem (mlp); 1086 mlp_delete_problem (mlp);
1094 start_build = GNUNET_TIME_absolute_get(); 1087 start_build = GNUNET_TIME_absolute_get();
1095 mlp_create_problem (mlp, addresses); 1088 if (GNUNET_SYSERR == mlp_create_problem (mlp, addresses))
1089 return GNUNET_SYSERR;
1096 duration_build = GNUNET_TIME_absolute_get_duration (start_build); 1090 duration_build = GNUNET_TIME_absolute_get_duration (start_build);
1097 mlp->control_param_lp.presolve = GLP_YES; 1091 mlp->control_param_lp.presolve = GLP_YES;
1092 mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */
1098 } 1093 }
1099 else 1094 else
1100 { 1095 {
@@ -1120,6 +1115,11 @@ GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addr
1120 mlp->ps.build_dur = duration_build; 1115 mlp->ps.build_dur = duration_build;
1121 mlp->ps.lp_dur = duration_lp; 1116 mlp->ps.lp_dur = duration_lp;
1122 mlp->ps.mip_dur = duration_mlp; 1117 mlp->ps.mip_dur = duration_mlp;
1118 mlp->ps.lp_presolv = mlp->control_param_lp.presolve;
1119 mlp->ps.mip_presolv = mlp->control_param_mlp.presolve;
1120 mlp->ps.p_cols = glp_get_num_cols (mlp->p.prob);
1121 mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob);
1122 mlp->ps.p_elements = mlp->p.num_elements;
1123 1123
1124 LOG (GNUNET_ERROR_TYPE_DEBUG, "Execution time: Build %llu ms, LP %llu ms, MLP %llu ms\n", 1124 LOG (GNUNET_ERROR_TYPE_DEBUG, "Execution time: Build %llu ms, LP %llu ms, MLP %llu ms\n",
1125 (unsigned long long) duration_build.rel_value, 1125 (unsigned long long) duration_build.rel_value,
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
index d80736124..235b7d14d 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.h
+++ b/src/ats/gnunet-service-ats_addresses_mlp.h
@@ -39,8 +39,8 @@
39 39
40#define MLP_AVERAGING_QUEUE_LENGTH 3 40#define MLP_AVERAGING_QUEUE_LENGTH 3
41 41
42#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) 42#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
43#define MLP_MAX_ITERATIONS 1024 43#define MLP_MAX_ITERATIONS 4096
44 44
45#define DEFAULT_D 1.0 45#define DEFAULT_D 1.0
46#define DEFAULT_R 1.0 46#define DEFAULT_R 1.0
@@ -61,7 +61,17 @@ struct MLP_Solution
61 struct GNUNET_TIME_Relative mip_dur; 61 struct GNUNET_TIME_Relative mip_dur;
62 62
63 int lp_res; 63 int lp_res;
64 int lp_presolv;
64 int mip_res; 65 int mip_res;
66 int mip_presolv;
67
68 int p_elements;
69 int p_cols;
70 int p_rows;
71
72 int n_peers;
73 int n_addresses;
74
65}; 75};
66 76
67struct ATS_Peer 77struct ATS_Peer
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index 4769842c8..c615a57b9 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -126,12 +126,6 @@ end_now (int res)
126 ret = res; 126 ret = res;
127} 127}
128 128
129static void
130end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
131{
132
133}
134
135 129
136static void 130static void
137bandwidth_changed_cb (void *cls, struct ATS_Address *address) 131bandwidth_changed_cb (void *cls, struct ATS_Address *address)
@@ -237,11 +231,16 @@ check (void *cls, char *const *args, const char *cfgfile,
237 { 231 {
238 232
239 GAS_mlp_solve_problem (mlp, addresses); 233 GAS_mlp_solve_problem (mlp, addresses);
240 fprintf (stderr, "Solving problem for %u peers with each %u addresses (build/LP/MIP in ms): %llu %llu %llu\n", 234 fprintf (stderr, "%u peers each %u addresses; state [%s/%s], (build/LP/MIP in ms): %04llu %04llu %04llu; presolv LP/MIP [%s/%s]; size (cols x rows, nonzero elements): [%u x %u] = %u\n",
241 cp + 1, ca, 235 cp + 1, ca,
236 (GNUNET_OK == mlp->ps.lp_res) ? "OK" : "FAIL",
237 (GNUNET_OK == mlp->ps.mip_res) ? "OK" : "FAIL",
242 (unsigned long long) mlp->ps.build_dur.rel_value, 238 (unsigned long long) mlp->ps.build_dur.rel_value,
243 (unsigned long long) mlp->ps.lp_dur.rel_value, 239 (unsigned long long) mlp->ps.lp_dur.rel_value,
244 (unsigned long long) mlp->ps.mip_dur.rel_value); 240 (unsigned long long) mlp->ps.mip_dur.rel_value,
241 (GLP_YES == mlp->ps.lp_presolv) ? "YES" : "NO",
242 (GNUNET_OK == mlp->ps.mip_presolv) ? "YES" : "NO",
243 mlp->ps.p_cols, mlp->ps.p_rows, mlp->ps.p_elements);
245 } 244 }
246 245
247 } 246 }
@@ -287,7 +286,6 @@ main (int argc, char *argv[])
287 if (0 != atoi(argv[c+1])) 286 if (0 != atoi(argv[c+1]))
288 { 287 {
289 N_peers_start = atoi(argv[c+1]); 288 N_peers_start = atoi(argv[c+1]);
290 fprintf (stderr, "peers_start: %u\n",N_peers_start );
291 } 289 }
292 } 290 }
293 if ((0 == strcmp (argv[c], "-w")) && (c < argc)) 291 if ((0 == strcmp (argv[c], "-w")) && (c < argc))
@@ -295,7 +293,6 @@ main (int argc, char *argv[])
295 if (0 != atoi(argv[c+1])) 293 if (0 != atoi(argv[c+1]))
296 { 294 {
297 N_peers_end = atoi(argv[c+1]); 295 N_peers_end = atoi(argv[c+1]);
298 fprintf (stderr, "peers_end: %u\n",N_peers_end );
299 } 296 }
300 } 297 }
301 if ((0 == strcmp (argv[c], "-a")) && (c < argc)) 298 if ((0 == strcmp (argv[c], "-a")) && (c < argc))
@@ -303,7 +300,6 @@ main (int argc, char *argv[])
303 if (0 != atoi(argv[c+1])) 300 if (0 != atoi(argv[c+1]))
304 { 301 {
305 N_address = atoi(argv[c+1]); 302 N_address = atoi(argv[c+1]);
306 fprintf (stderr, "address: %u\n",N_address );
307 } 303 }
308 } 304 }
309 } 305 }