aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-17 18:49:56 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-17 18:49:56 +0000
commit99a42c9ecb14e3c987d9c750c5c9290192e239de (patch)
treed204cadb367e650ad72d7397afb1b67d29cee552 /src
parentee070fe6f1caa8fbf81d770c8685939a91b2cbc5 (diff)
downloadgnunet-99a42c9ecb14e3c987d9c750c5c9290192e239de.tar.gz
gnunet-99a42c9ecb14e3c987d9c750c5c9290192e239de.zip
better
Diffstat (limited to 'src')
-rw-r--r--src/datastore/perf_datastore_api.c105
1 files changed, 61 insertions, 44 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 3d4f45806..bb04efc09 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.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 Christian Grothoff (and other contributing authors) 3 (C) 2004, 2005, 2006, 2007, 2009 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
@@ -22,15 +22,14 @@
22 * @brief performance measurement for the datastore implementation 22 * @brief performance measurement for the datastore implementation
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * 24 *
25 * This testcase inserts a bunch of (variable size) data and then deletes 25 * This testcase inserts a bunch of (variable size) data and then
26 * data until the (reported) database size drops below a given threshold. 26 * deletes data until the (reported) database size drops below a given
27 * This is iterated 10 times, with the actual size of the content stored, 27 * threshold. This is iterated 10 times, with the actual size of the
28 * the database size reported and the file size on disk being printed for 28 * content stored and the number of operations performed being printed
29 * each iteration. The code also prints a "I" for every 40 blocks 29 * for each iteration. The code also prints a "I" for every 40 blocks
30 * inserted and a "D" for every 40 blocks deleted. The deletion 30 * inserted and a "D" for every 40 blocks deleted. The deletion
31 * strategy alternates between "lowest priority" and "earliest expiration". 31 * strategy uses the "random" iterator. Priorities and expiration
32 * Priorities and expiration dates are set using a pseudo-random value 32 * dates are set using a pseudo-random value within a realistic range.
33 * within a realistic range.
34 */ 33 */
35 34
36#include "platform.h" 35#include "platform.h"
@@ -128,6 +127,10 @@ struct CpsRunContext
128 int j; 127 int j;
129 unsigned long long size; 128 unsigned long long size;
130 int i; 129 int i;
130
131 GNUNET_HashCode key;
132 uint32_t esize;
133 char data[65536];
131}; 134};
132 135
133 136
@@ -190,30 +193,51 @@ remove_next(void *cls,
190 int success, 193 int success,
191 const char *msg) 194 const char *msg)
192{ 195{
196 static int dc;
197 dc++;
198#if REPORT_ID
199 if (dc % REP_FREQ == 0)
200 fprintf (stderr, "D");
201#endif
193 GNUNET_assert (GNUNET_OK == success); 202 GNUNET_assert (GNUNET_OK == success);
194} 203}
195 204
196 205
206
207static void
208do_delete (void *cls,
209 const struct GNUNET_SCHEDULER_TaskContext *tc)
210{
211 struct CpsRunContext *crc = cls;
212
213 GNUNET_DATASTORE_remove (datastore,
214 &crc->key,
215 crc->esize,
216 crc->data,
217 &remove_next,
218 crc);
219}
220
221
222
197static void 223static void
198delete_value (void *cls, 224delete_value (void *cls,
199 const GNUNET_HashCode * key, 225 const GNUNET_HashCode * key,
200 uint32_t size, 226 uint32_t size,
201 const void *data, 227 const void *data,
202 uint32_t type, 228 uint32_t type,
203 uint32_t priority, 229 uint32_t priority,
204 uint32_t anonymity, 230 uint32_t anonymity,
205 struct GNUNET_TIME_Absolute 231 struct GNUNET_TIME_Absolute
206 expiration, uint64_t uid) 232 expiration, uint64_t uid)
207{ 233{
208 struct CpsRunContext *crc = cls; 234 struct CpsRunContext *crc = cls;
209 235
210 /* FIXME: should probably abort deletion iteration 236 if (stored_bytes < MAX_SIZE)
211 earlier (to not delete everything...) */ 237 return;
212 if (key == NULL) 238 if (key == NULL)
213 { 239 {
214 crc->phase = RP_REPORT; 240 crc->phase = RP_REPORT;
215 /* FIXME: should wait for all "remove_next" calls
216 to complete before going back to the run_continuation */
217 GNUNET_SCHEDULER_add_continuation (crc->sched, 241 GNUNET_SCHEDULER_add_continuation (crc->sched,
218 GNUNET_NO, 242 GNUNET_NO,
219 &run_continuation, 243 &run_continuation,
@@ -221,16 +245,20 @@ delete_value (void *cls,
221 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 245 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
222 return; 246 return;
223 } 247 }
224 GNUNET_DATASTORE_remove (datastore, 248 stored_bytes -= size;
225 key, 249 stored_entries--;
226 size, 250 crc->key = *key;
227 data, 251 crc->esize = size;
228 &remove_next, 252 memcpy (crc->data, data, size);
229 crc); 253 GNUNET_SCHEDULER_add_after (crc->sched,
254 GNUNET_NO,
255 GNUNET_SCHEDULER_PRIORITY_HIGH,
256 GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
257 &do_delete,
258 crc);
230} 259}
231 260
232 261
233
234static void 262static void
235run_continuation (void *cls, 263run_continuation (void *cls,
236 const struct GNUNET_SCHEDULER_TaskContext *tc) 264 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -276,19 +304,9 @@ run_continuation (void *cls,
276 break; 304 break;
277 case RP_CUT: 305 case RP_CUT:
278 /* trim down below MAX_SIZE again */ 306 /* trim down below MAX_SIZE again */
279 if ((i % 2) == 0) 307 GNUNET_DATASTORE_get_random (datastore,
280 { 308 &delete_value,
281 GNUNET_DATASTORE_get_random (datastore, 309 crc);
282 &delete_value,
283 crc);
284 break;
285 }
286 crc->phase = RP_REPORT;
287 GNUNET_SCHEDULER_add_continuation (crc->sched,
288 GNUNET_NO,
289 &run_continuation,
290 crc,
291 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
292 break; 310 break;
293 case RP_REPORT: 311 case RP_REPORT:
294 size = 0; 312 size = 0;
@@ -341,7 +359,8 @@ static int
341check () 359check ()
342{ 360{
343 pid_t pid; 361 pid_t pid;
344 char *const argv[] = { "perf-datastore-api", 362 char *const argv[] = {
363 "perf-datastore-api",
345 "-c", 364 "-c",
346 "test_datastore_api_data.conf", 365 "test_datastore_api_data.conf",
347#if VERBOSE 366#if VERBOSE
@@ -368,8 +387,6 @@ check ()
368 ok = 1; 387 ok = 1;
369 } 388 }
370 GNUNET_OS_process_wait(pid); 389 GNUNET_OS_process_wait(pid);
371 if (ok != 0)
372 fprintf (stderr, "Missed some testcases: %u\n", ok);
373 return ok; 390 return ok;
374} 391}
375 392