aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/perf_datastore_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-08-03 10:44:37 +0000
committerChristian Grothoff <christian@grothoff.org>2015-08-03 10:44:37 +0000
commitf4acc7da5d674b80115290a6f631467fc34f0826 (patch)
tree2345ea3698a3bf97b43b27d20dbd6c9b3beb4a7b /src/datastore/perf_datastore_api.c
parent722a93c626d4033abbb221f44238fd7e25f99b0d (diff)
downloadgnunet-f4acc7da5d674b80115290a6f631467fc34f0826.tar.gz
gnunet-f4acc7da5d674b80115290a6f631467fc34f0826.zip
extend datastore performance tests to cover scenario described in #3903 -- but no issue discovered
Diffstat (limited to 'src/datastore/perf_datastore_api.c')
-rw-r--r--src/datastore/perf_datastore_api.c95
1 files changed, 85 insertions, 10 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index c3dbad00a..bd92eb4c6 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -46,7 +46,7 @@
46/** 46/**
47 * Target datastore size (in bytes). 47 * Target datastore size (in bytes).
48 */ 48 */
49#define MAX_SIZE 1024LL * 1024 * 4 49#define MAX_SIZE (1024LL * 1024 * 4)
50 50
51/** 51/**
52 * Report progress outside of major reports? Should probably be #GNUNET_YES if 52 * Report progress outside of major reports? Should probably be #GNUNET_YES if
@@ -66,6 +66,13 @@
66 */ 66 */
67#define ITERATIONS 8 67#define ITERATIONS 8
68 68
69/**
70 * Total number of iterations to do to go beyond the quota.
71 * The quota is set to 10 MB or 2.5 times #MAX_SIZE,
72 * so we got 16 times #MAX_SIZE to be sure to hit it a LOT.
73 */
74#define QUOTA_PUTS (MAX_SIZE / 32 / 1024 * 16LL)
75
69 76
70/** 77/**
71 * Number of bytes stored in the datastore in total. 78 * Number of bytes stored in the datastore in total.
@@ -125,6 +132,12 @@ enum RunPhase
125 RP_CUT, 132 RP_CUT,
126 133
127 /** 134 /**
135 * We are putting as much as we can to see how the database performs
136 * when it reaches the quota and has to auto-delete (see #3903).
137 */
138 RP_PUT_QUOTA,
139
140 /**
128 * We are generating a report. 141 * We are generating a report.
129 */ 142 */
130 RP_REPORT, 143 RP_REPORT,
@@ -199,6 +212,9 @@ check_success (void *cls,
199{ 212{
200 struct CpsRunContext *crc = cls; 213 struct CpsRunContext *crc = cls;
201 214
215#if REPORT_ID
216 FPRINTF (stderr, "%s", (GNUNET_OK == success) ? "I" : "i");
217#endif
202 if (GNUNET_OK != success) 218 if (GNUNET_OK != success)
203 { 219 {
204 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -209,21 +225,32 @@ check_success (void *cls,
209 crc); 225 crc);
210 return; 226 return;
211 } 227 }
212#if REPORT_ID
213 FPRINTF (stderr, "%s", "I");
214#endif
215 stored_bytes += crc->size; 228 stored_bytes += crc->size;
216 stored_ops++; 229 stored_ops++;
217 stored_entries++; 230 stored_entries++;
218 crc->j++; 231 crc->j++;
219 if (crc->j >= PUT_10) 232 switch (crc->phase)
220 { 233 {
221 crc->j = 0; 234 case RP_PUT:
222 crc->i++; 235 if (crc->j >= PUT_10)
223 if (crc->i == ITERATIONS) 236 {
237 crc->j = 0;
238 crc->i++;
239 if (crc->i == ITERATIONS)
240 crc->phase = RP_PUT_QUOTA;
241 else
242 crc->phase = RP_CUT;
243 }
244 break;
245 case RP_PUT_QUOTA:
246 if (crc->j >= QUOTA_PUTS)
247 {
248 crc->j = 0;
224 crc->phase = RP_DONE; 249 crc->phase = RP_DONE;
225 else 250 }
226 crc->phase = RP_CUT; 251 break;
252 default:
253 GNUNET_assert (0);
227 } 254 }
228 GNUNET_SCHEDULER_add_now (&run_continuation, 255 GNUNET_SCHEDULER_add_now (&run_continuation,
229 crc); 256 crc);
@@ -329,6 +356,8 @@ run_continuation (void *cls,
329 static char data[65536]; 356 static char data[65536];
330 char gstr[128]; 357 char gstr[128];
331 358
359 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
360 crc->phase = RP_ERROR;
332 ok = (int) crc->phase; 361 ok = (int) crc->phase;
333 switch (crc->phase) 362 switch (crc->phase)
334 { 363 {
@@ -401,6 +430,52 @@ run_continuation (void *cls,
401 GNUNET_SCHEDULER_add_now (&run_continuation, 430 GNUNET_SCHEDULER_add_now (&run_continuation,
402 crc); 431 crc);
403 break; 432 break;
433 case RP_PUT_QUOTA:
434 memset (&key,
435 256 - crc->i,
436 sizeof (struct GNUNET_HashCode));
437 /* most content is 32k */
438 size = 32 * 1024;
439 if (0 ==
440 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
441 16)) /* but some of it is less! */
442 size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
443 32 * 1024);
444 crc->size = size = size - (size & 7); /* always multiple of 8 */
445 GNUNET_CRYPTO_hash (&key,
446 sizeof (struct GNUNET_HashCode),
447 &key);
448 memset (data,
449 (int) crc->j,
450 size);
451 if (crc->j > 255)
452 memset (data,
453 (int) (crc->j - 255),
454 size / 2);
455 data[0] = crc->i;
456 GNUNET_assert (NULL !=
457 GNUNET_DATASTORE_put (datastore,
458 0, /* reservation ID */
459 &key,
460 size,
461 data,
462 crc->j + 1, /* type */
463 GNUNET_CRYPTO_random_u32
464 (GNUNET_CRYPTO_QUALITY_WEAK,
465 100), /* priority */
466 crc->j, /* anonymity */
467 0, /* replication */
468 GNUNET_TIME_relative_to_absolute
469 (GNUNET_TIME_relative_multiply
470 (GNUNET_TIME_UNIT_SECONDS,
471 GNUNET_CRYPTO_random_u32
472 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))),
473 1,
474 1,
475 TIMEOUT,
476 &check_success, crc));
477 break;
478
404 case RP_DONE: 479 case RP_DONE:
405 GNUNET_snprintf (gstr, 480 GNUNET_snprintf (gstr,
406 sizeof (gstr), 481 sizeof (gstr),