diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-05 14:07:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-05 14:07:10 +0000 |
commit | c0ef1c0414caf5d3f3e886df18584665026f9af8 (patch) | |
tree | bf9854a87c75cfc0d5ef375e3c07a7337ebaf0c9 /src/datastore/perf_plugin_datastore.c | |
parent | 887d927606be4def2e195da47e567009955fb679 (diff) | |
download | gnunet-c0ef1c0414caf5d3f3e886df18584665026f9af8.tar.gz gnunet-c0ef1c0414caf5d3f3e886df18584665026f9af8.zip |
insanity
Diffstat (limited to 'src/datastore/perf_plugin_datastore.c')
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 235 |
1 files changed, 172 insertions, 63 deletions
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index c21d9551b..940dd9b97 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2004, 2005, 2006, 2007, 2009, 2011 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -27,6 +27,7 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_protocols.h" | 28 | #include "gnunet_protocols.h" |
29 | #include "gnunet_datastore_plugin.h" | 29 | #include "gnunet_datastore_plugin.h" |
30 | #include <gauger.h> | ||
30 | 31 | ||
31 | #define VERBOSE GNUNET_NO | 32 | #define VERBOSE GNUNET_NO |
32 | 33 | ||
@@ -45,6 +46,10 @@ | |||
45 | */ | 46 | */ |
46 | #define PUT_10 (MAX_SIZE / 32 / 1024 / ITERATIONS) | 47 | #define PUT_10 (MAX_SIZE / 32 / 1024 / ITERATIONS) |
47 | 48 | ||
49 | static char category[256]; | ||
50 | |||
51 | static unsigned int hits[PUT_10 / 8 + 1]; | ||
52 | |||
48 | static unsigned long long stored_bytes; | 53 | static unsigned long long stored_bytes; |
49 | 54 | ||
50 | static unsigned long long stored_entries; | 55 | static unsigned long long stored_entries; |
@@ -57,11 +62,12 @@ static int ok; | |||
57 | 62 | ||
58 | enum RunPhase | 63 | enum RunPhase |
59 | { | 64 | { |
60 | RP_DONE = 0, | 65 | RP_ERROR = 0, |
61 | RP_PUT, | 66 | RP_PUT, |
62 | RP_LP_GET, | 67 | RP_REP_GET, |
63 | RP_AE_GET, | 68 | RP_ZA_GET, |
64 | RP_ZA_GET | 69 | RP_EXP_GET, |
70 | RP_DONE | ||
65 | }; | 71 | }; |
66 | 72 | ||
67 | 73 | ||
@@ -72,7 +78,6 @@ struct CpsRunContext | |||
72 | struct GNUNET_TIME_Absolute end; | 78 | struct GNUNET_TIME_Absolute end; |
73 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 79 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
74 | struct GNUNET_DATASTORE_PluginFunctions * api; | 80 | struct GNUNET_DATASTORE_PluginFunctions * api; |
75 | const char *msg; | ||
76 | enum RunPhase phase; | 81 | enum RunPhase phase; |
77 | unsigned int cnt; | 82 | unsigned int cnt; |
78 | }; | 83 | }; |
@@ -105,9 +110,8 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | |||
105 | 110 | ||
106 | /* most content is 32k */ | 111 | /* most content is 32k */ |
107 | size = 32 * 1024; | 112 | size = 32 * 1024; |
108 | |||
109 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */ | 113 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */ |
110 | size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024); | 114 | size = 8 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024); |
111 | size = size - (size & 7); /* always multiple of 8 */ | 115 | size = size - (size & 7); /* always multiple of 8 */ |
112 | 116 | ||
113 | /* generate random key */ | 117 | /* generate random key */ |
@@ -117,15 +121,16 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | |||
117 | if (i > 255) | 121 | if (i > 255) |
118 | memset (value, i - 255, size / 2); | 122 | memset (value, i - 255, size / 2); |
119 | value[0] = k; | 123 | value[0] = k; |
124 | memcpy (&value[4], &i, sizeof (i)); | ||
120 | msg = NULL; | 125 | msg = NULL; |
121 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 126 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
122 | if (GNUNET_OK != api->put (api->cls, | 127 | if (GNUNET_OK != api->put (api->cls, |
123 | &key, | 128 | &key, |
124 | size, | 129 | size, |
125 | value, | 130 | value, |
126 | i /* type */, | 131 | 1 + i % 4 /* type */, |
127 | prio, | 132 | prio, |
128 | i /* anonymity */, | 133 | i % 4 /* anonymity */, |
129 | 0 /* replication */, | 134 | 0 /* replication */, |
130 | GNUNET_TIME_relative_to_absolute | 135 | GNUNET_TIME_relative_to_absolute |
131 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 136 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
@@ -149,7 +154,7 @@ test (void *cls, | |||
149 | 154 | ||
150 | 155 | ||
151 | static int | 156 | static int |
152 | iterateDummy (void *cls, | 157 | iterate_zeros (void *cls, |
153 | void *next_cls, | 158 | void *next_cls, |
154 | const GNUNET_HashCode * key, | 159 | const GNUNET_HashCode * key, |
155 | uint32_t size, | 160 | uint32_t size, |
@@ -162,31 +167,49 @@ iterateDummy (void *cls, | |||
162 | uint64_t uid) | 167 | uint64_t uid) |
163 | { | 168 | { |
164 | struct CpsRunContext *crc = cls; | 169 | struct CpsRunContext *crc = cls; |
165 | 170 | int i; | |
171 | const char *cdata = data; | ||
172 | |||
166 | if (key == NULL) | 173 | if (key == NULL) |
167 | { | 174 | { |
175 | char buf[256]; | ||
176 | unsigned int bc; | ||
177 | |||
178 | bc = 0; | ||
179 | for (i = 0;i<PUT_10;i++) | ||
180 | if (0 != (hits[i/8] & (1 << (i % 8)))) | ||
181 | bc++; | ||
182 | |||
168 | crc->end = GNUNET_TIME_absolute_get(); | 183 | crc->end = GNUNET_TIME_absolute_get(); |
169 | printf (crc->msg, | 184 | GNUNET_snprintf (buf, sizeof (buf), |
170 | crc->i, | 185 | "Iteration over %u zero-anonymity items", |
186 | crc->cnt); | ||
187 | printf ("%s took %llu ms yielding %u/%u items\n", | ||
188 | buf, | ||
171 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | 189 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), |
190 | bc, | ||
172 | crc->cnt); | 191 | crc->cnt); |
173 | if (crc->phase != RP_ZA_GET) | 192 | GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms"); |
174 | { | 193 | memset (hits, 0, sizeof (hits)); |
175 | crc->phase++; | 194 | if ( (int) (PUT_10 / 4 - crc->cnt) > 2) |
176 | } | ||
177 | else | ||
178 | { | 195 | { |
179 | if (crc->i == ITERATIONS) | 196 | fprintf (stderr, |
180 | crc->phase = RP_DONE; | 197 | "Got %d items, expected %d\n", |
181 | else | 198 | (int) crc->cnt, (int) PUT_10 / 4); |
182 | crc->phase = RP_PUT; | 199 | GNUNET_break (0); |
200 | crc->phase = RP_ERROR; | ||
183 | } | 201 | } |
202 | crc->phase++; | ||
184 | crc->cnt = 0; | 203 | crc->cnt = 0; |
185 | crc->start = GNUNET_TIME_absolute_get (); | 204 | crc->start = GNUNET_TIME_absolute_get (); |
186 | GNUNET_SCHEDULER_add_now (&test, crc); | 205 | GNUNET_SCHEDULER_add_now (&test, crc); |
187 | return GNUNET_OK; | 206 | return GNUNET_OK; |
188 | } | 207 | } |
189 | #if VERBOSE | 208 | GNUNET_assert (size >= 8); |
209 | memcpy (&i, &cdata[4], sizeof (i)); | ||
210 | hits[i/8] |= (1 << (i % 8)); | ||
211 | |||
212 | #if VERBOSE | ||
190 | fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | 213 | fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n", |
191 | type, priority, size, | 214 | type, priority, size, |
192 | (unsigned long long) expiration.abs_value); | 215 | (unsigned long long) expiration.abs_value); |
@@ -198,38 +221,110 @@ iterateDummy (void *cls, | |||
198 | } | 221 | } |
199 | 222 | ||
200 | 223 | ||
224 | static int | ||
225 | expiration_get (void *cls, | ||
226 | void *next_cls, | ||
227 | const GNUNET_HashCode * key, | ||
228 | uint32_t size, | ||
229 | const void *data, | ||
230 | enum GNUNET_BLOCK_Type type, | ||
231 | uint32_t priority, | ||
232 | uint32_t anonymity, | ||
233 | struct GNUNET_TIME_Absolute | ||
234 | expiration, | ||
235 | uint64_t uid) | ||
236 | { | ||
237 | struct CpsRunContext *crc = cls; | ||
238 | int i; | ||
239 | const char *cdata = data; | ||
240 | |||
241 | GNUNET_assert (size >= 8); | ||
242 | memcpy (&i, &cdata[4], sizeof (i)); | ||
243 | hits[i/8] |= (1 << (i % 8)); | ||
244 | crc->cnt++; | ||
245 | if (PUT_10 == crc->cnt) | ||
246 | { | ||
247 | char buf[256]; | ||
248 | unsigned int bc; | ||
249 | |||
250 | bc = 0; | ||
251 | for (i = 0;i<PUT_10;i++) | ||
252 | if (0 != (hits[i/8] & (1 << (i % 8)))) | ||
253 | bc++; | ||
254 | |||
255 | crc->end = GNUNET_TIME_absolute_get(); | ||
256 | GNUNET_snprintf (buf, sizeof (buf), | ||
257 | "Execution of %u expiration+deletion-GET requests", | ||
258 | PUT_10); | ||
259 | printf ("%s took %llu ms yielding %u/%u items\n", | ||
260 | buf, | ||
261 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | ||
262 | bc, | ||
263 | (unsigned int) PUT_10); | ||
264 | GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms"); | ||
265 | memset (hits, 0, sizeof (hits)); | ||
266 | crc->phase++; | ||
267 | crc->cnt = 0; | ||
268 | crc->start = GNUNET_TIME_absolute_get (); | ||
269 | } | ||
270 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
271 | return GNUNET_NO; | ||
272 | } | ||
273 | |||
201 | 274 | ||
202 | static int | 275 | static int |
203 | dummy_get (void *cls, | 276 | replication_get (void *cls, |
204 | void *next_cls, | 277 | void *next_cls, |
205 | const GNUNET_HashCode * key, | 278 | const GNUNET_HashCode * key, |
206 | uint32_t size, | 279 | uint32_t size, |
207 | const void *data, | 280 | const void *data, |
208 | enum GNUNET_BLOCK_Type type, | 281 | enum GNUNET_BLOCK_Type type, |
209 | uint32_t priority, | 282 | uint32_t priority, |
210 | uint32_t anonymity, | 283 | uint32_t anonymity, |
211 | struct GNUNET_TIME_Absolute | 284 | struct GNUNET_TIME_Absolute |
212 | expiration, | 285 | expiration, |
213 | uint64_t uid) | 286 | uint64_t uid) |
214 | { | 287 | { |
215 | struct CpsRunContext *crc = cls; | 288 | struct CpsRunContext *crc = cls; |
289 | int i; | ||
290 | const char *cdata = data; | ||
216 | 291 | ||
292 | GNUNET_assert (NULL != key); | ||
293 | GNUNET_assert (size >= 8); | ||
294 | memcpy (&i, &cdata[4], sizeof (i)); | ||
295 | hits[i/8] |= (1 << (i % 8)); | ||
217 | crc->cnt++; | 296 | crc->cnt++; |
218 | if (1000 == crc->cnt) | 297 | if (PUT_10 == crc->cnt) |
219 | { | 298 | { |
299 | char buf[256]; | ||
300 | unsigned int bc; | ||
301 | |||
302 | bc = 0; | ||
303 | for (i = 0;i<PUT_10;i++) | ||
304 | if (0 != (hits[i/8] & (1 << (i % 8)))) | ||
305 | bc++; | ||
306 | |||
220 | crc->end = GNUNET_TIME_absolute_get(); | 307 | crc->end = GNUNET_TIME_absolute_get(); |
221 | printf (crc->msg, | 308 | GNUNET_snprintf (buf, sizeof (buf), |
222 | crc->i, | 309 | "Execution of %u replication-GET requests", |
310 | PUT_10); | ||
311 | printf ("%s took %llu ms yielding %u/%u items\n", | ||
312 | buf, | ||
223 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | 313 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), |
224 | crc->cnt); | 314 | bc, |
315 | (unsigned int) PUT_10); | ||
316 | GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms"); | ||
317 | memset (hits, 0, sizeof (hits)); | ||
225 | crc->phase++; | 318 | crc->phase++; |
226 | crc->cnt = 0; | 319 | crc->cnt = 0; |
227 | crc->start = GNUNET_TIME_absolute_get (); | 320 | crc->start = GNUNET_TIME_absolute_get (); |
228 | } | 321 | } |
322 | |||
229 | GNUNET_SCHEDULER_add_now (&test, crc); | 323 | GNUNET_SCHEDULER_add_now (&test, crc); |
230 | return GNUNET_OK; | 324 | return GNUNET_OK; |
231 | } | 325 | } |
232 | 326 | ||
327 | |||
233 | /** | 328 | /** |
234 | * Function called when the service shuts | 329 | * Function called when the service shuts |
235 | * down. Unloads our datastore plugin. | 330 | * down. Unloads our datastore plugin. |
@@ -284,47 +379,57 @@ test (void *cls, | |||
284 | int j; | 379 | int j; |
285 | 380 | ||
286 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 381 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
287 | { | 382 | crc->phase = RP_ERROR; |
288 | crc->phase = RP_DONE; | ||
289 | ok = 1; | ||
290 | } | ||
291 | switch (crc->phase) | 383 | switch (crc->phase) |
292 | { | 384 | { |
385 | case RP_ERROR: | ||
386 | GNUNET_break (0); | ||
387 | crc->api->drop (crc->api->cls); | ||
388 | ok = 1; | ||
389 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
390 | &cleaning_task, crc); | ||
391 | break; | ||
293 | case RP_PUT: | 392 | case RP_PUT: |
294 | crc->start = GNUNET_TIME_absolute_get (); | 393 | crc->start = GNUNET_TIME_absolute_get (); |
295 | for (j=0;j<PUT_10;j++) | 394 | for (j=0;j<PUT_10;j++) |
296 | putValue (crc->api, j, crc->i); | 395 | putValue (crc->api, j, crc->i); |
297 | crc->end = GNUNET_TIME_absolute_get (); | 396 | crc->end = GNUNET_TIME_absolute_get (); |
298 | printf ("%3u insertion took %20llums for %u\n", | 397 | { |
299 | crc->i, | 398 | char buf[256]; |
300 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | 399 | |
301 | (unsigned int) PUT_10); | 400 | GNUNET_snprintf (buf, sizeof (buf), |
401 | "Execution of %u PUT requests", | ||
402 | PUT_10); | ||
403 | printf ("%s took %llu ms\n", | ||
404 | buf, | ||
405 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value)); | ||
406 | GAUGER (category, | ||
407 | buf, crc->end.abs_value - crc->start.abs_value, "ms"); | ||
408 | } | ||
302 | crc->i++; | 409 | crc->i++; |
303 | crc->start = GNUNET_TIME_absolute_get (); | 410 | crc->start = GNUNET_TIME_absolute_get (); |
304 | crc->phase = RP_LP_GET; | 411 | crc->phase++; |
305 | GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, | 412 | GNUNET_SCHEDULER_add_now (&test, crc); |
306 | &test, crc); | ||
307 | break; | 413 | break; |
308 | case RP_LP_GET: | 414 | case RP_REP_GET: |
309 | crc->msg = "%3u replication iteration took %20llums for %u\n"; | ||
310 | crc->api->replication_get (crc->api->cls, | 415 | crc->api->replication_get (crc->api->cls, |
311 | &dummy_get, | 416 | &replication_get, |
312 | crc); | 417 | crc); |
313 | break; | 418 | break; |
314 | case RP_AE_GET: | ||
315 | crc->msg = "%3u expiration iteration took %20llums for %u\n"; | ||
316 | crc->api->expiration_get (crc->api->cls, | ||
317 | &dummy_get, | ||
318 | crc); | ||
319 | break; | ||
320 | case RP_ZA_GET: | 419 | case RP_ZA_GET: |
321 | crc->msg = "%3u zero anonymity iteration took %20llums for %u\n"; | 420 | crc->api->iter_zero_anonymity (crc->api->cls, 1, |
322 | crc->api->iter_zero_anonymity (crc->api->cls, 0, | 421 | &iterate_zeros, |
323 | &iterateDummy, | ||
324 | crc); | 422 | crc); |
325 | break; | 423 | break; |
424 | case RP_EXP_GET: | ||
425 | crc->api->expiration_get (crc->api->cls, | ||
426 | &expiration_get, | ||
427 | crc); | ||
428 | break; | ||
326 | case RP_DONE: | 429 | case RP_DONE: |
430 | exit (0); | ||
327 | crc->api->drop (crc->api->cls); | 431 | crc->api->drop (crc->api->cls); |
432 | ok = 0; | ||
328 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 433 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
329 | &cleaning_task, crc); | 434 | &cleaning_task, crc); |
330 | break; | 435 | break; |
@@ -392,6 +497,7 @@ run (void *cls, | |||
392 | crc->api = api; | 497 | crc->api = api; |
393 | crc->cfg = c; | 498 | crc->cfg = c; |
394 | crc->phase = RP_PUT; | 499 | crc->phase = RP_PUT; |
500 | ok = 2; | ||
395 | GNUNET_SCHEDULER_add_now (&test, crc); | 501 | GNUNET_SCHEDULER_add_now (&test, crc); |
396 | } | 502 | } |
397 | 503 | ||
@@ -413,6 +519,9 @@ check () | |||
413 | GNUNET_GETOPT_OPTION_END | 519 | GNUNET_GETOPT_OPTION_END |
414 | }; | 520 | }; |
415 | 521 | ||
522 | GNUNET_snprintf (category, sizeof (category), | ||
523 | "DATASTORE-%s", | ||
524 | plugin_name); | ||
416 | GNUNET_snprintf (cfg_name, | 525 | GNUNET_snprintf (cfg_name, |
417 | sizeof (cfg_name), | 526 | sizeof (cfg_name), |
418 | "perf_plugin_datastore_data_%s.conf", | 527 | "perf_plugin_datastore_data_%s.conf", |