[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36186 - gnunet/src/datastore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36186 - gnunet/src/datastore |
Date: |
Mon, 3 Aug 2015 12:44:37 +0200 |
Author: grothoff
Date: 2015-08-03 12:44:37 +0200 (Mon, 03 Aug 2015)
New Revision: 36186
Modified:
gnunet/src/datastore/perf_datastore_api.c
Log:
extend datastore performance tests to cover scenario described in #3903 -- but
no issue discovered
Modified: gnunet/src/datastore/perf_datastore_api.c
===================================================================
--- gnunet/src/datastore/perf_datastore_api.c 2015-08-03 10:29:09 UTC (rev
36185)
+++ gnunet/src/datastore/perf_datastore_api.c 2015-08-03 10:44:37 UTC (rev
36186)
@@ -46,7 +46,7 @@
/**
* Target datastore size (in bytes).
*/
-#define MAX_SIZE 1024LL * 1024 * 4
+#define MAX_SIZE (1024LL * 1024 * 4)
/**
* Report progress outside of major reports? Should probably be #GNUNET_YES if
@@ -66,7 +66,14 @@
*/
#define ITERATIONS 8
+/**
+ * Total number of iterations to do to go beyond the quota.
+ * The quota is set to 10 MB or 2.5 times #MAX_SIZE,
+ * so we got 16 times #MAX_SIZE to be sure to hit it a LOT.
+ */
+#define QUOTA_PUTS (MAX_SIZE / 32 / 1024 * 16LL)
+
/**
* Number of bytes stored in the datastore in total.
*/
@@ -125,6 +132,12 @@
RP_CUT,
/**
+ * We are putting as much as we can to see how the database performs
+ * when it reaches the quota and has to auto-delete (see #3903).
+ */
+ RP_PUT_QUOTA,
+
+ /**
* We are generating a report.
*/
RP_REPORT,
@@ -199,6 +212,9 @@
{
struct CpsRunContext *crc = cls;
+#if REPORT_ID
+ FPRINTF (stderr, "%s", (GNUNET_OK == success) ? "I" : "i");
+#endif
if (GNUNET_OK != success)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -209,21 +225,32 @@
crc);
return;
}
-#if REPORT_ID
- FPRINTF (stderr, "%s", "I");
-#endif
stored_bytes += crc->size;
stored_ops++;
stored_entries++;
crc->j++;
- if (crc->j >= PUT_10)
+ switch (crc->phase)
{
- crc->j = 0;
- crc->i++;
- if (crc->i == ITERATIONS)
+ case RP_PUT:
+ if (crc->j >= PUT_10)
+ {
+ crc->j = 0;
+ crc->i++;
+ if (crc->i == ITERATIONS)
+ crc->phase = RP_PUT_QUOTA;
+ else
+ crc->phase = RP_CUT;
+ }
+ break;
+ case RP_PUT_QUOTA:
+ if (crc->j >= QUOTA_PUTS)
+ {
+ crc->j = 0;
crc->phase = RP_DONE;
- else
- crc->phase = RP_CUT;
+ }
+ break;
+ default:
+ GNUNET_assert (0);
}
GNUNET_SCHEDULER_add_now (&run_continuation,
crc);
@@ -329,6 +356,8 @@
static char data[65536];
char gstr[128];
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ crc->phase = RP_ERROR;
ok = (int) crc->phase;
switch (crc->phase)
{
@@ -401,6 +430,52 @@
GNUNET_SCHEDULER_add_now (&run_continuation,
crc);
break;
+ case RP_PUT_QUOTA:
+ memset (&key,
+ 256 - crc->i,
+ sizeof (struct GNUNET_HashCode));
+ /* most content is 32k */
+ size = 32 * 1024;
+ if (0 ==
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 16)) /* but some of it is less! */
+ size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 32 * 1024);
+ crc->size = size = size - (size & 7); /* always multiple of 8 */
+ GNUNET_CRYPTO_hash (&key,
+ sizeof (struct GNUNET_HashCode),
+ &key);
+ memset (data,
+ (int) crc->j,
+ size);
+ if (crc->j > 255)
+ memset (data,
+ (int) (crc->j - 255),
+ size / 2);
+ data[0] = crc->i;
+ GNUNET_assert (NULL !=
+ GNUNET_DATASTORE_put (datastore,
+ 0, /* reservation ID */
+ &key,
+ size,
+ data,
+ crc->j + 1, /* type */
+ GNUNET_CRYPTO_random_u32
+ (GNUNET_CRYPTO_QUALITY_WEAK,
+ 100), /* priority */
+ crc->j, /* anonymity */
+ 0, /* replication */
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS,
+ GNUNET_CRYPTO_random_u32
+ (GNUNET_CRYPTO_QUALITY_WEAK,
1000))),
+ 1,
+ 1,
+ TIMEOUT,
+ &check_success, crc));
+ break;
+
case RP_DONE:
GNUNET_snprintf (gstr,
sizeof (gstr),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36186 - gnunet/src/datastore,
gnunet <=