aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-02-26 13:31:58 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-02-26 13:31:58 +0000
commitffb83798933660d0d5106193e1f6d55fb7c9a3fe (patch)
treed455fa6d1c94a6a83dd406af2cea6eb15b61046f
parent6bed1381ac84900728ed55e6ecee9ff3db178a1a (diff)
downloadgnunet-ffb83798933660d0d5106193e1f6d55fb7c9a3fe.tar.gz
gnunet-ffb83798933660d0d5106193e1f6d55fb7c9a3fe.zip
perf
-rw-r--r--src/ats/Makefile.am4
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c9
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h13
-rw-r--r--src/ats/perf_ats_mlp.c309
-rw-r--r--src/ats/test_ats_mlp.conf4
5 files changed, 166 insertions, 173 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index dd4eea4be..e93cc11c1 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -74,8 +74,8 @@ check_PROGRAMS = \
74 test_ats_simplistic_change_preference \ 74 test_ats_simplistic_change_preference \
75 test_ats_simplistic_pref_aging \ 75 test_ats_simplistic_pref_aging \
76 test_ats_api_performance \ 76 test_ats_api_performance \
77 $(GN_MLP_TEST) 77 $(GN_MLP_TEST) $(GN_MLP_PERF)
78# $(GN_MLP_TEST_AVG) $(GN_MLP_PERF)\ 78# $(GN_MLP_TEST_AVG)
79# test_ats_api_scheduling_get_type 79# test_ats_api_scheduling_get_type
80# test_ats_api_bandwidth_consumption 80# test_ats_api_bandwidth_consumption
81 81
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 3e03e6adc..fc1bdf2e0 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -1061,7 +1061,6 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value
1061 1061
1062 1062
1063 1063
1064
1065/** 1064/**
1066 * Solves the MLP problem 1065 * Solves the MLP problem
1067 * 1066 *
@@ -1108,12 +1107,20 @@ GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addr
1108 start_lp = GNUNET_TIME_absolute_get(); 1107 start_lp = GNUNET_TIME_absolute_get();
1109 res = mlp_solve_lp_problem (mlp); 1108 res = mlp_solve_lp_problem (mlp);
1110 duration_lp = GNUNET_TIME_absolute_get_duration (start_lp); 1109 duration_lp = GNUNET_TIME_absolute_get_duration (start_lp);
1110 mlp->ps.lp_res = res;
1111 1111
1112 /* Run LP solver */ 1112 /* Run LP solver */
1113 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n"); 1113 LOG (GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n");
1114 start_mlp = GNUNET_TIME_absolute_get(); 1114 start_mlp = GNUNET_TIME_absolute_get();
1115 res = mlp_solve_mlp_problem (mlp); 1115 res = mlp_solve_mlp_problem (mlp);
1116
1116 duration_mlp = GNUNET_TIME_absolute_get_duration (start_mlp); 1117 duration_mlp = GNUNET_TIME_absolute_get_duration (start_mlp);
1118 mlp->ps.mip_res = res;
1119
1120 mlp->ps.build_dur = duration_build;
1121 mlp->ps.lp_dur = duration_lp;
1122 mlp->ps.mip_dur = duration_mlp;
1123
1117 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",
1118 (unsigned long long) duration_build.rel_value, 1125 (unsigned long long) duration_build.rel_value,
1119 (unsigned long long) duration_lp.rel_value, 1126 (unsigned long long) duration_lp.rel_value,
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
index c4a1718cd..d80736124 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.h
+++ b/src/ats/gnunet-service-ats_addresses_mlp.h
@@ -53,6 +53,17 @@
53#define GLP_YES 1.0 53#define GLP_YES 1.0
54#define GLP_NO 0.0 54#define GLP_NO 0.0
55 55
56
57struct MLP_Solution
58{
59 struct GNUNET_TIME_Relative build_dur;
60 struct GNUNET_TIME_Relative lp_dur;
61 struct GNUNET_TIME_Relative mip_dur;
62
63 int lp_res;
64 int mip_res;
65};
66
56struct ATS_Peer 67struct ATS_Peer
57{ 68{
58 struct GNUNET_PeerIdentity id; 69 struct GNUNET_PeerIdentity id;
@@ -214,6 +225,8 @@ struct GAS_MLP_Handle
214 225
215 struct MLP_Variables pv; 226 struct MLP_Variables pv;
216 227
228 struct MLP_Solution ps;
229
217 /** 230 /**
218 * GLPK LP control parameter 231 * GLPK LP control parameter
219 */ 232 */
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index ff0e8c4b3..4769842c8 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -58,91 +58,65 @@
58#include "gnunet-service-ats_addresses_mlp.h" 58#include "gnunet-service-ats_addresses_mlp.h"
59#include "test_ats_api_common.h" 59#include "test_ats_api_common.h"
60 60
61#define PEERS_START 1 61#define PEERS_START 100
62#define PEERS_END 100 62#define PEERS_END 100
63 63
64/** 64#define ADDRESSES 10
65 * Return value
66 */
67static int ret;
68 65
69/** 66int count_p;
70 * MLP solver handle 67int count_a;
71 */
72struct GAS_MLP_Handle *mlp;
73 68
74 69
75/** 70struct PerfPeer
76 * Statistics handle 71{
77 */ 72 struct GNUNET_PeerIdentity id;
78struct GNUNET_STATISTICS_Handle * stats;
79 73
80/** 74 struct ATS_Address *head;
81 * Hashmap containing addresses 75 struct ATS_Address *tail;
82 */ 76};
83struct GNUNET_CONTAINER_MultiHashMap * addresses; 77
78static int ret;
79
80static int N_peers_start;
81static int N_peers_end;
82static int N_address;
84 83
85/** 84/**
86 * Peer 85 * Statistics handle
87 */ 86 */
88struct GNUNET_PeerIdentity p[2]; 87struct GNUNET_STATISTICS_Handle * stats;
89 88
90/** 89/**
91 * ATS Address 90 * MLP solver handle
92 */ 91 */
93struct ATS_Address *address[3]; 92struct GAS_MLP_Handle *mlp;
94 93
95/** 94/**
96 * Timeout task 95 * Hashmap containing addresses
97 */ 96 */
98GNUNET_SCHEDULER_TaskIdentifier timeout_task; 97struct GNUNET_CONTAINER_MultiHashMap * addresses;
99
100
101#if 0
102
103#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
104#define MLP_MAX_ITERATIONS INT_MAX
105
106static void
107set_ats (struct GNUNET_ATS_Information *ats, uint32_t type, uint32_t value)
108{
109 ats->type = type;
110 ats->value = value;
111}
112
113#endif
114
115int addr_it (void *cls,
116 const struct GNUNET_HashCode * key,
117 void *value)
118{
119 struct ATS_Address *address = (struct ATS_Address *) value;
120 GAS_mlp_address_delete (mlp, addresses, address, GNUNET_NO);
121 GNUNET_CONTAINER_multihashmap_remove (addresses, key, value);
122 GNUNET_free (address);
123 return GNUNET_OK;
124}
125 98
99struct PerfPeer *peers;
126 100
127static void 101static void
128end_now (int res) 102end_now (int res)
129{ 103{
130 if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
131 {
132 GNUNET_SCHEDULER_cancel (timeout_task);
133 timeout_task = GNUNET_SCHEDULER_NO_TASK;
134 }
135 if (NULL != stats) 104 if (NULL != stats)
136 { 105 {
137 GNUNET_STATISTICS_destroy(stats, GNUNET_NO); 106 GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
138 stats = NULL; 107 stats = NULL;
139 } 108 }
109 /*
140 if (NULL != addresses) 110 if (NULL != addresses)
141 { 111 {
142 GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it, NULL); 112 GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it, NULL);
143 GNUNET_CONTAINER_multihashmap_destroy (addresses); 113 GNUNET_CONTAINER_multihashmap_destroy (addresses);
144 addresses = NULL ; 114 addresses = NULL ;
145 } 115 }*/
116 if (NULL != peers)
117 {
118 GNUNET_free (peers);
119 }
146 if (NULL != mlp) 120 if (NULL != mlp)
147 { 121 {
148 GAS_mlp_done (mlp); 122 GAS_mlp_done (mlp);
@@ -155,49 +129,37 @@ end_now (int res)
155static void 129static void
156end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 130end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
157{ 131{
158 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test ending with success\n")); 132
159 end_now (0);
160} 133}
161 134
135
162static void 136static void
163end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 137bandwidth_changed_cb (void *cls, struct ATS_Address *address)
164{ 138{
165 timeout_task = GNUNET_SCHEDULER_NO_TASK;
166 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test ending with timeout\n"));
167 end_now (1);
168}
169 139
140}
170 141
171static void 142static void
172bandwidth_changed_cb (void *cls, struct ATS_Address *address) 143perf_create_peer (int cp)
144{
145 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &peers[cp].id.hashPubKey);
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating peer #%u: %s \n", cp, GNUNET_i2s (&peers[cp].id));
147}
148
149static struct ATS_Address *
150perf_create_address (int cp, int ca)
173{ 151{
174 static int cb_p0 = GNUNET_NO; 152 struct ATS_Address *a;
175 static int cb_p1 = GNUNET_NO; 153 a = create_address (&peers[cp].id, "Test 1", "test 1", strlen ("test 1") + 1, 0);
176 154 GNUNET_CONTAINER_DLL_insert (peers[cp].head, peers[cp].tail, a);
177 unsigned long long in = ntohl(address->assigned_bw_in.value__); 155 GNUNET_CONTAINER_multihashmap_put (addresses, &peers[cp].id.hashPubKey, a, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
178 unsigned long long out = ntohl(address->assigned_bw_out.value__); 156 return a;
179
180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP suggests for peer `%s' address `%s':`%s' in %llu out %llu \n",
181 GNUNET_i2s(&address->peer),
182 address->plugin,
183 address->addr,
184 in, out);
185
186 if ((in > 0) && (out > 0) &&
187 (0 == memcmp(&p[0], &address->peer, sizeof (address->peer))))
188 cb_p0 ++;
189
190 if ((in > 0) && (out > 0) &&
191 (0 == memcmp(&p[1], &address->peer, sizeof (address->peer))))
192 cb_p1 ++;
193
194 if ((1 == cb_p0) && (1 == cb_p1))
195 GNUNET_SCHEDULER_add_now (&end_correctly, NULL);
196 else if ((1 > cb_p0) || (1 > cb_p1))
197 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
198} 157}
199 158
200 159
160
161
162
201static void 163static void
202check (void *cls, char *const *args, const char *cfgfile, 164check (void *cls, char *const *args, const char *cfgfile,
203 const struct GNUNET_CONFIGURATION_Handle *cfg) 165 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -205,17 +167,9 @@ check (void *cls, char *const *args, const char *cfgfile,
205 int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; 167 int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
206 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; 168 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
207 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; 169 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
208 //struct GNUNET_ATS_Information ats; 170 int cp;
209 171 int ca;
210#if !HAVE_LIBGLPK 172 struct ATS_Address * cur_addr;
211 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
212 ret = 1;
213 return;
214#endif
215
216
217
218 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
219 173
220 stats = GNUNET_STATISTICS_create("ats", cfg); 174 stats = GNUNET_STATISTICS_create("ats", cfg);
221 if (NULL == stats) 175 if (NULL == stats)
@@ -234,8 +188,25 @@ check (void *cls, char *const *args, const char *cfgfile,
234 return; 188 return;
235 } 189 }
236 190
191 GNUNET_assert (N_peers_end >= N_peers_start);
192 GNUNET_assert (N_address >= 0);
193
194 if ((0 == N_peers_start) && (0 == N_peers_end))
195 {
196 N_peers_start = PEERS_START;
197 N_peers_end = PEERS_END;
198 }
199 if (0 == N_address)
200 N_address = ADDRESSES;
201
202 fprintf (stderr, "Solving problem for %u..%u peers with %u addresses\n",
203 N_peers_start, N_peers_end, N_address);
204
205 count_p = N_peers_end;
206 count_a = N_address;
207 peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
237 /* Setup address hashmap */ 208 /* Setup address hashmap */
238 addresses = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); 209 addresses = GNUNET_CONTAINER_multihashmap_create (N_address, GNUNET_NO);
239 210
240 /* Init MLP solver */ 211 /* Init MLP solver */
241 mlp = GAS_mlp_init (cfg, stats, quotas, quotas_out, quotas_in, 212 mlp = GAS_mlp_init (cfg, stats, quotas, quotas_out, quotas_in,
@@ -248,77 +219,49 @@ check (void *cls, char *const *args, const char *cfgfile,
248 } 219 }
249 mlp->mlp_auto_solve = GNUNET_NO; 220 mlp->mlp_auto_solve = GNUNET_NO;
250 221
222 for (cp = 0; cp < count_p; cp++)
223 perf_create_peer (cp);
251 224
252#if 0 225 for (cp = 0; cp < count_p; cp++)
253 226 {
254 /* Create peer 0 */ 227 for (ca = 0; ca < count_a; ca++)
255 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].hashPubKey)) 228 {
256 { 229 cur_addr = perf_create_address(cp, ca);
257 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); 230 /* add address */
258 end_now (1); 231 GAS_mlp_address_add (mlp, addresses, cur_addr);
259 return; 232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer %u address %u: \n", cp, ca);
260 } 233 }
261 234 GAS_mlp_get_preferred_address( mlp, addresses, &peers[cp].id);
262 /* Create peer 1 */ 235 /* solve */
263 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].hashPubKey)) 236 if (cp + 1 >= N_peers_start)
264 { 237 {
265 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); 238
266 end_now (1); 239 GAS_mlp_solve_problem (mlp, addresses);
267 return; 240 fprintf (stderr, "Solving problem for %u peers with each %u addresses (build/LP/MIP in ms): %llu %llu %llu\n",
268 } 241 cp + 1, ca,
269 242 (unsigned long long) mlp->ps.build_dur.rel_value,
270 /* Create address 0 */ 243 (unsigned long long) mlp->ps.lp_dur.rel_value,
271 address[0] = create_address (&p[0], "test_plugin0", "test_addr0", strlen("test_addr0")+1, 0); 244 (unsigned long long) mlp->ps.mip_dur.rel_value);
272 if (NULL == address[0]) 245 }
273 {
274 GNUNET_break (0);
275 end_now (1);
276 return;
277 }
278 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
279 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
280 /* Adding address 0 */
281 GAS_mlp_address_add (mlp, addresses, address[0]);
282
283 /* Create address 1 */
284 address[1] = create_address (&p[0], "test_plugin1", "test_addr1", strlen("test_addr1")+1, 0);
285 if (NULL == address[1])
286 {
287 GNUNET_break (0);
288 end_now (1);
289 return;
290 }
291 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[1],
292 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
293 /* Adding address 1*/
294 GAS_mlp_address_add (mlp, addresses, address[1]);
295
296 246
297 /* Create address 3 */ 247 }
298 address[2] = create_address (&p[1], "test_plugin2", "test_addr2", strlen("test_addr2")+1, 0);
299 if (NULL == address[2])
300 {
301 GNUNET_break (0);
302 end_now (1);
303 return;
304 }
305 GNUNET_CONTAINER_multihashmap_put (addresses, &p[1].hashPubKey, address[2],
306 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
307 /* Adding address 3*/
308 GAS_mlp_address_add (mlp, addresses, address[2]);
309 248
310 249
311 /* Updating address 0*/ 250 struct ATS_Address *cur;
312 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 251 struct ATS_Address *next;
313 ats.value = htonl (GNUNET_ATS_NET_WAN); 252 for (cp = 0; cp < count_p; cp++)
314 GAS_mlp_address_update (mlp, addresses, address[0], 1, GNUNET_NO, &ats, 1); 253 {
254 for (cur = peers[cp].head; cur != NULL; cur = next)
255 {
256 GAS_mlp_address_delete (mlp, addresses, cur, GNUNET_NO);
257 next = cur->next;
258 GNUNET_CONTAINER_DLL_remove (peers[cp].head, peers[cp].tail, cur);
259 GNUNET_free (cur);
260 }
315 261
316 /* Retrieving preferred address for peer and wait for callback */ 262 }
317 GAS_mlp_get_preferred_address (mlp, addresses, &p[0]); 263 GNUNET_free (peers);
318 GAS_mlp_get_preferred_address (mlp, addresses, &p[1]);
319 264
320 GAS_mlp_solve_problem (mlp, addresses);
321#endif
322} 265}
323 266
324 267
@@ -333,10 +276,43 @@ main (int argc, char *argv[])
333 NULL 276 NULL
334 }; 277 };
335 278
336 static struct GNUNET_GETOPT_CommandLineOption options[] = { 279 N_peers_start = 0;
280 N_peers_end = 0;
281 N_address = 0;
282 int c;
283 for (c = 0; c < argc; c++)
284 {
285 if ((0 == strcmp (argv[c], "-q")) && (c < argc))
286 {
287 if (0 != atoi(argv[c+1]))
288 {
289 N_peers_start = atoi(argv[c+1]);
290 fprintf (stderr, "peers_start: %u\n",N_peers_start );
291 }
292 }
293 if ((0 == strcmp (argv[c], "-w")) && (c < argc))
294 {
295 if (0 != atoi(argv[c+1]))
296 {
297 N_peers_end = atoi(argv[c+1]);
298 fprintf (stderr, "peers_end: %u\n",N_peers_end );
299 }
300 }
301 if ((0 == strcmp (argv[c], "-a")) && (c < argc))
302 {
303 if (0 != atoi(argv[c+1]))
304 {
305 N_address = atoi(argv[c+1]);
306 fprintf (stderr, "address: %u\n",N_address );
307 }
308 }
309 }
310
311 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
337 GNUNET_GETOPT_OPTION_END 312 GNUNET_GETOPT_OPTION_END
338 }; 313 };
339 314
315
340 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 316 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
341 "perf_ats_mlp", "nohelp", options, 317 "perf_ats_mlp", "nohelp", options,
342 &check, NULL); 318 &check, NULL);
@@ -345,7 +321,4 @@ main (int argc, char *argv[])
345 return ret; 321 return ret;
346} 322}
347 323
348/* end of file test_ats_api_bandwidth_consumption.c */
349
350
351/* end of file perf_ats_mlp.c */ 324/* end of file perf_ats_mlp.c */
diff --git a/src/ats/test_ats_mlp.conf b/src/ats/test_ats_mlp.conf
index 25d885d11..f64c783f6 100644
--- a/src/ats/test_ats_mlp.conf
+++ b/src/ats/test_ats_mlp.conf
@@ -23,8 +23,8 @@ UNIX_MATCH_GID = YES
23MODE = MLP 23MODE = MLP
24# Network specific inbound/outbound quotas 24# Network specific inbound/outbound quotas
25# UNSPECIFIED 25# UNSPECIFIED
26UNSPECIFIED_QUOTA_IN = 64 KiB 26UNSPECIFIED_QUOTA_IN = unlimited
27UNSPECIFIED_QUOTA_OUT = 64 KiB 27UNSPECIFIED_QUOTA_OUT = unlimited
28# LOOPBACK 28# LOOPBACK
29LOOPBACK_QUOTA_IN = unlimited 29LOOPBACK_QUOTA_IN = unlimited
30LOOPBACK_QUOTA_OUT = unlimited 30LOOPBACK_QUOTA_OUT = unlimited