aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/perf_plugin_datastore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-04-26 18:19:15 +0000
committerChristian Grothoff <christian@grothoff.org>2011-04-26 18:19:15 +0000
commit27ed8fcbc85a361864948edb517d47804c2b5a56 (patch)
tree01626713ea5b2ead4691f13eb66a1574b1c0c7fd /src/datastore/perf_plugin_datastore.c
parentb6c71d97d2a4bb3cb0e0e0ac1cd2a4e145748cc6 (diff)
downloadgnunet-27ed8fcbc85a361864948edb517d47804c2b5a56.tar.gz
gnunet-27ed8fcbc85a361864948edb517d47804c2b5a56.zip
datastore and fs fixes from Easter
Diffstat (limited to 'src/datastore/perf_plugin_datastore.c')
-rw-r--r--src/datastore/perf_plugin_datastore.c78
1 files changed, 37 insertions, 41 deletions
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index 2903a8f28..6befa120c 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -37,7 +37,7 @@
37 * those take too long to run them in the usual "make check" 37 * those take too long to run them in the usual "make check"
38 * sequence. Hence the value used for shipping is tiny. 38 * sequence. Hence the value used for shipping is tiny.
39 */ 39 */
40#define MAX_SIZE 1024LL * 1024 * 128 40#define MAX_SIZE 1024LL * 1024 * 32
41 41
42#define ITERATIONS 2 42#define ITERATIONS 2
43 43
@@ -81,6 +81,7 @@ struct CpsRunContext
81 enum RunPhase phase; 81 enum RunPhase phase;
82 unsigned int cnt; 82 unsigned int cnt;
83 unsigned int iter; 83 unsigned int iter;
84 uint64_t offset;
84}; 85};
85 86
86 87
@@ -100,7 +101,8 @@ disk_utilization_change_cb (void *cls,
100 101
101 102
102static void 103static void
103putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) 104putValue (struct GNUNET_DATASTORE_PluginFunctions * api,
105 int i, int k)
104{ 106{
105 char value[65536]; 107 char value[65536];
106 size_t size; 108 size_t size;
@@ -156,7 +158,6 @@ test (void *cls,
156 158
157static int 159static int
158iterate_zeros (void *cls, 160iterate_zeros (void *cls,
159 void *next_cls,
160 const GNUNET_HashCode * key, 161 const GNUNET_HashCode * key,
161 uint32_t size, 162 uint32_t size,
162 const void *data, 163 const void *data,
@@ -171,7 +172,18 @@ iterate_zeros (void *cls,
171 int i; 172 int i;
172 const char *cdata = data; 173 const char *cdata = data;
173 174
174 if (key == NULL) 175 GNUNET_assert (key != NULL);
176 GNUNET_assert (size >= 8);
177 memcpy (&i, &cdata[4], sizeof (i));
178 hits[i/8] |= (1 << (i % 8));
179
180#if VERBOSE
181 fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n",
182 type, priority, size,
183 (unsigned long long) expiration.abs_value);
184#endif
185 crc->cnt++;
186 if (crc->cnt == PUT_10 / 4 - 1)
175 { 187 {
176 char buf[256]; 188 char buf[256];
177 unsigned int bc; 189 unsigned int bc;
@@ -192,42 +204,17 @@ iterate_zeros (void *cls,
192 crc->cnt); 204 crc->cnt);
193 GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms"); 205 GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms");
194 memset (hits, 0, sizeof (hits)); 206 memset (hits, 0, sizeof (hits));
195 if ( (int) (PUT_10 / 4 - crc->cnt) > 2) 207 crc->phase++;
196 { 208 crc->cnt = 0;
197 fprintf (stderr, 209 crc->start = GNUNET_TIME_absolute_get ();
198 "Got %d items, expected %d\n",
199 (int) crc->cnt, (int) PUT_10 / 4);
200 GNUNET_break (0);
201 crc->phase = RP_ERROR;
202 }
203 else
204 {
205 crc->phase++;
206 crc->cnt = 0;
207 crc->start = GNUNET_TIME_absolute_get ();
208 }
209 GNUNET_SCHEDULER_add_now (&test, crc);
210 return GNUNET_OK;
211 } 210 }
212 GNUNET_assert (size >= 8); 211 GNUNET_SCHEDULER_add_now (&test, crc);
213 memcpy (&i, &cdata[4], sizeof (i));
214 hits[i/8] |= (1 << (i % 8));
215
216#if VERBOSE
217 fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n",
218 type, priority, size,
219 (unsigned long long) expiration.abs_value);
220#endif
221 crc->cnt++;
222 crc->api->next_request (next_cls,
223 GNUNET_NO);
224 return GNUNET_OK; 212 return GNUNET_OK;
225} 213}
226 214
227 215
228static int 216static int
229expiration_get (void *cls, 217expiration_get (void *cls,
230 void *next_cls,
231 const GNUNET_HashCode * key, 218 const GNUNET_HashCode * key,
232 uint32_t size, 219 uint32_t size,
233 const void *data, 220 const void *data,
@@ -281,7 +268,6 @@ expiration_get (void *cls,
281 268
282static int 269static int
283replication_get (void *cls, 270replication_get (void *cls,
284 void *next_cls,
285 const GNUNET_HashCode * key, 271 const GNUNET_HashCode * key,
286 uint32_t size, 272 uint32_t size,
287 const void *data, 273 const void *data,
@@ -323,6 +309,7 @@ replication_get (void *cls,
323 GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms"); 309 GAUGER (category, buf, crc->end.abs_value - crc->start.abs_value, "ms");
324 memset (hits, 0, sizeof (hits)); 310 memset (hits, 0, sizeof (hits));
325 crc->phase++; 311 crc->phase++;
312 crc->offset = 0;
326 crc->cnt = 0; 313 crc->cnt = 0;
327 crc->start = GNUNET_TIME_absolute_get (); 314 crc->start = GNUNET_TIME_absolute_get ();
328 } 315 }
@@ -386,7 +373,15 @@ test (void *cls,
386 int j; 373 int j;
387 374
388 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 375 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
389 crc->phase = RP_ERROR; 376 {
377 GNUNET_break (0);
378 crc->phase = RP_ERROR;
379 }
380#if VERBOSE
381 fprintf (stderr, "In phase %d, iteration %u\n",
382 crc->phase,
383 crc->cnt);
384#endif
390 switch (crc->phase) 385 switch (crc->phase)
391 { 386 {
392 case RP_ERROR: 387 case RP_ERROR:
@@ -419,17 +414,19 @@ test (void *cls,
419 GNUNET_SCHEDULER_add_now (&test, crc); 414 GNUNET_SCHEDULER_add_now (&test, crc);
420 break; 415 break;
421 case RP_REP_GET: 416 case RP_REP_GET:
422 crc->api->replication_get (crc->api->cls, 417 crc->api->get_replication (crc->api->cls,
423 &replication_get, 418 &replication_get,
424 crc); 419 crc);
425 break; 420 break;
426 case RP_ZA_GET: 421 case RP_ZA_GET:
427 crc->api->iter_zero_anonymity (crc->api->cls, 1, 422 crc->api->get_zero_anonymity (crc->api->cls,
428 &iterate_zeros, 423 crc->offset++,
429 crc); 424 1,
425 &iterate_zeros,
426 crc);
430 break; 427 break;
431 case RP_EXP_GET: 428 case RP_EXP_GET:
432 crc->api->expiration_get (crc->api->cls, 429 crc->api->get_expiration (crc->api->cls,
433 &expiration_get, 430 &expiration_get,
434 crc); 431 crc);
435 break; 432 break;
@@ -549,7 +546,6 @@ main (int argc, char *argv[])
549 char *pos; 546 char *pos;
550 char dir_name[128]; 547 char dir_name[128];
551 548
552 if (1) return 0;
553 /* determine name of plugin to use */ 549 /* determine name of plugin to use */
554 plugin_name = argv[0]; 550 plugin_name = argv[0];
555 while (NULL != (pos = strstr(plugin_name, "_"))) 551 while (NULL != (pos = strstr(plugin_name, "_")))