From 3373631cffc0a20831553700eca90f665a1814e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Sun, 3 Mar 2024 17:38:23 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-test:=20=D1=83=D0=BD=D0=B8=D1=84=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20PRNG=20=D0=B8=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=BF=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8=20=D0=BD=D0=B0=20?= =?UTF-8?q?`--prng-seed`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/CMakeLists.txt | 4 +- test/append.c++ | 6 +-- test/cases.c++ | 13 +++--- test/config.c++ | 2 +- test/config.h++ | 1 + test/hill.c++ | 2 +- test/keygen.c++ | 4 +- test/keygen.h++ | 3 +- test/long_stochastic.sh | 95 +++++++++++++++++------------------------ test/main.c++ | 10 +++-- test/nested.c++ | 5 +-- test/test.c++ | 4 +- test/test.h++ | 9 ++-- test/ttl.c++ | 5 +-- test/utils.c++ | 2 +- test/utils.h++ | 1 + 16 files changed, 75 insertions(+), 91 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ac11ef63..7098cfed 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -122,7 +122,7 @@ else() add_test(NAME smoke COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=verbose - --keygen.seed=${test_seed} + --prng-seed=${test_seed} --progress --console=no --pathname=smoke.db --dont-cleanup-after basic) set_tests_properties(smoke PROPERTIES TIMEOUT 600 @@ -144,7 +144,7 @@ else() add_test(NAME dupsort_writemap COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=notice - --keygen.seed=${test_seed} + --prng-seed=${test_seed} --table=+data.integer --keygen.split=29 --datalen.min=min --datalen.max=max --progress --console=no --repeat=2 --pathname=dupsort_writemap.db --dont-cleanup-after basic) set_tests_properties(dupsort_writemap PROPERTIES diff --git a/test/append.c++ b/test/append.c++ index d2486001..5c7adf3d 100644 --- a/test/append.c++ +++ b/test/append.c++ @@ -20,8 +20,8 @@ public: : testcase(config, pid) {} bool run() override; - static bool review_params(actor_params ¶ms) { - if (!testcase::review_params(params)) + static bool review_params(actor_params ¶ms, unsigned space_id) { + if (!testcase::review_params(params, space_id)) return false; const bool ordered = !flipcoin_x3(); log_notice("the '%s' key-generation mode is selected", @@ -45,7 +45,7 @@ bool testcase_append::run() { } cursor_open(dbi); - keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */); + keyvalue_maker.setup(config.params, 0 /* thread_number */); /* LY: тест наполнения таблиц в append-режиме, * при котором записи добавляются строго в конец (в порядке сортировки) */ const MDBX_put_flags_t flags = diff --git a/test/cases.c++ b/test/cases.c++ index 5ccb87ae..1c650a91 100644 --- a/test/cases.c++ +++ b/test/cases.c++ @@ -41,8 +41,9 @@ testcase *registry::create_actor(const actor_config &config, } bool registry::review_actor_params(const actor_testcase id, - actor_params ¶ms) { - return instance()->id2record.at(id)->review_params(params); + actor_params ¶ms, + const unsigned space_id) { + return instance()->id2record.at(id)->review_params(params, space_id); } //----------------------------------------------------------------------------- @@ -78,13 +79,13 @@ void configure_actor(unsigned &last_space_id, const actor_testcase testcase, failure("The '%s' is unexpected for space-id\n", end); } - if (!registry::review_actor_params(testcase, params)) - failure("Actor config-review failed for space-id %lu\n", space_id); - if (space_id > ACTOR_ID_MAX) failure("Invalid space-id %lu\n", space_id); - last_space_id = unsigned(space_id); + if (!registry::review_actor_params(testcase, params, unsigned(space_id))) + failure("Actor config-review failed for space-id %lu\n", space_id); + + last_space_id = unsigned(space_id); log_trace("configure_actor: space %lu for %s", space_id, testcase2str(testcase)); global::actors.emplace_back( diff --git a/test/config.c++ b/test/config.c++ index acad8fb6..f675dee1 100644 --- a/test/config.c++ +++ b/test/config.c++ @@ -434,6 +434,7 @@ void dump(const char *title) { log_verbose("#%u, testcase %s, space_id/table %u\n", i->actor_id, testcase2str(i->testcase), i->space_id); indent.push(); + log_verbose("prng-seed: %u\n", i->params.prng_seed); if (i->params.loglevel) { log_verbose("log: level %u, %s\n", i->params.loglevel, @@ -473,7 +474,6 @@ void dump(const char *title) { i->params.keygen.mesh, i->params.keygen.rotate, i->params.keygen.offset, i->params.keygen.split, i->params.keygen.width - i->params.keygen.split); - log_verbose("keygen.seed: %u\n", i->params.keygen.seed); log_verbose("keygen.zerofill: %s\n", i->params.keygen.zero_fill ? "Yes" : "No"); log_verbose("key: minlen %u, maxlen %u\n", i->params.keylen_min, diff --git a/test/config.h++ b/test/config.h++ index be369171..18617e34 100644 --- a/test/config.h++ +++ b/test/config.h++ @@ -274,6 +274,7 @@ struct actor_params_pod { unsigned batch_read{0}; unsigned batch_write{0}; + unsigned prng_seed{0}; unsigned delaystart{0}; unsigned waitfor_nops{0}; unsigned inject_writefaultn{0}; diff --git a/test/hill.c++ b/test/hill.c++ index 79234b7d..f5ca1026 100644 --- a/test/hill.c++ +++ b/test/hill.c++ @@ -52,7 +52,7 @@ bool testcase_hill::run() { speculum_committed.clear(); /* TODO: работа в несколько потоков */ - keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */); + keyvalue_maker.setup(config.params, 0 /* thread_number */); keygen::buffer a_key = keygen::alloc(config.params.keylen_max); keygen::buffer a_data_0 = keygen::alloc(config.params.datalen_max); diff --git a/test/keygen.c++ b/test/keygen.c++ index 1829e0db..46b64ecf 100644 --- a/test/keygen.c++ +++ b/test/keygen.c++ @@ -188,7 +188,7 @@ void __hot maker::pair(serial_t serial, const buffer &key, buffer &value, log_pair(logging::trace, "kv", key, value); } -void maker::setup(const config::actor_params_pod &actor, unsigned actor_id, +void maker::setup(const config::actor_params_pod &actor, unsigned thread_number) { #if CONSTEXPR_ENUM_FLAGS_OPERATIONS static_assert(unsigned(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT | @@ -238,7 +238,7 @@ void maker::setup(const config::actor_params_pod &actor, unsigned actor_id, mapping.width -= 1; salt = - (actor.keygen.seed + uint64_t(actor_id)) * UINT64_C(14653293970879851569); + (prng_state + uint64_t(thread_number)) * UINT64_C(14653293970879851569); base = actor.serial_base(); } diff --git a/test/keygen.h++ b/test/keygen.h++ index 8c49eabb..0ded8130 100644 --- a/test/keygen.h++ +++ b/test/keygen.h++ @@ -121,8 +121,7 @@ class maker { public: void pair(serial_t serial, const buffer &key, buffer &value, serial_t value_age, const bool keylen_changeable); - void setup(const config::actor_params_pod &actor, unsigned actor_id, - unsigned thread_number); + void setup(const config::actor_params_pod &actor, unsigned thread_number); bool is_unordered() const; void seek2end(serial_t &serial) const; diff --git a/test/long_stochastic.sh b/test/long_stochastic.sh index ff73726c..b508b5f6 100755 --- a/test/long_stochastic.sh +++ b/test/long_stochastic.sh @@ -453,91 +453,72 @@ for nops in 10 33 100 333 1000 3333 10000 33333 100000 333333 1000000 3333333 10 split=30 caption="Probe #$((++count)) int-key,with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} split=24 caption="Probe #$((++count)) int-key,with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} split=16 caption="Probe #$((++count)) int-key,w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} if [ "$EXTRA" != "no" ]; then split=10 caption="Probe #$((++count)) int-key,w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) with-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} fi split=4 caption="Probe #$((++count)) int-key,w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) int-key,int-data, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=+key.integer,+data.integer --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=max \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} caption="Probe #$((++count)) w/o-dups, split=${split}, case $((++subcase)) of ${cases}" probe \ - --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ - --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} \ - --keygen.seed=${seed} + --prng-seed=${seed} --pagesize=$PAGESIZE --size-upper-upto=${db_size_mb}M --table=-data.dups --keygen.split=${split} --keylen.min=min --keylen.max=max --datalen.min=min --datalen.max=1111 \ + --nops=$nops --batch.write=$wbatch --mode=$(bits2options $bits)${syncmodes[count%4]} done # options loop=$((loop + 1)) if [ -n "$LOOPS" ] && [ $loop -ge "$LOOPS" ]; then break; fi diff --git a/test/main.c++ b/test/main.c++ index fe159142..84ab801c 100644 --- a/test/main.c++ +++ b/test/main.c++ @@ -37,6 +37,7 @@ MDBX_NORETURN void usage(void) { " --console[=yes/no] Enable/disable console-like output\n" " --cleanup-before[=YES/no] Cleanup/remove and re-create database\n" " --cleanup-after[=YES/no] Cleanup/remove database after completion\n" + " --prng-seed=N Seed PRNG\n" "Database size control:\n" " --pagesize=... Database page size: min, max, 256..65536\n" " --size-lower=N[K|M|G|T] Lower-bound of size in Kb/Mb/Gb/Tb\n" @@ -88,7 +89,6 @@ MDBX_NORETURN void usage(void) { " --datalen=N Set both min/max for data length\n" " --keygen.width=N TBD (see the source code)\n" " --keygen.mesh=N TBD (see the source code)\n" - " --keygen.seed=N TBD (see the source code)\n" " --keygen.zerofill=yes|NO TBD (see the source code)\n" " --keygen.split=N TBD (see the source code)\n" " --keygen.rotate=N TBD (see the source code)\n" @@ -144,7 +144,7 @@ void actor_params::set_defaults(const std::string &tmpdir) { growth_step = -1; pagesize = -1; - keygen.seed = 1; + prng_seed = 0; keygen.zero_fill = false; keygen.keycase = kc_random; keygen.width = (table_flags & MDBX_DUPSORT) ? 32 : 64; @@ -449,9 +449,11 @@ int main(int argc, char *const argv[]) { if (config::parse_option(argc, argv, narg, "keygen.mesh", params.keygen.mesh, 0, 64)) continue; - if (config::parse_option(argc, argv, narg, "keygen.seed", - params.keygen.seed, config::no_scale)) + if (config::parse_option(argc, argv, narg, "prng-seed", params.prng_seed, + config::no_scale)) { + prng_seed(params.prng_seed); continue; + } if (config::parse_option(argc, argv, narg, "keygen.zerofill", params.keygen.zero_fill)) continue; diff --git a/test/nested.c++ b/test/nested.c++ index 48299c79..55c7ab11 100644 --- a/test/nested.c++ +++ b/test/nested.c++ @@ -74,7 +74,7 @@ bool testcase_nested::setup() { return false; } - keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */); + keyvalue_maker.setup(config.params, 0 /* thread_number */); key = keygen::alloc(config.params.keylen_max); data = keygen::alloc(config.params.datalen_max); serial = 0; @@ -292,8 +292,7 @@ retry: } bool testcase_nested::run() { - uint64_t seed = - prng64_map2_white(config.params.keygen.seed) + config.actor_id; + uint64_t seed = prng64_map2_white(prng_state) + config.space_id; clear_wholetable_passed = 0; clear_stepbystep_passed = 0; diff --git a/test/test.c++ b/test/test.c++ index b2d9da86..10107980 100644 --- a/test/test.c++ +++ b/test/test.c++ @@ -668,8 +668,8 @@ bool test_execute(const actor_config &config_const) { size_t(config.params.nrepeat)); else log_verbose("test successfully (iteration %zi)", iter); - config.params.keygen.seed += INT32_C(0xA4F4D37B); - log_verbose("turn keygen to %u", config.params.keygen.seed); + prng_seed(config.params.prng_seed += INT32_C(0xA4F4D37B)); + log_verbose("turn PRNG to %u", config.params.prng_seed); } } while (config.params.nrepeat == 0 || iter < config.params.nrepeat); diff --git a/test/test.h++ b/test/test.h++ index b03b80e1..9db1bc6c 100644 --- a/test/test.h++ +++ b/test/test.h++ @@ -103,7 +103,7 @@ class registry { struct record { actor_testcase id = ac_none; std::string name; - bool (*review_params)(actor_params &) = nullptr; + bool (*review_params)(actor_params &, unsigned space_id) = nullptr; testcase *(*constructor)(const actor_config &, const mdbx_pid_t) = nullptr; }; std::unordered_map name2id; @@ -124,8 +124,8 @@ public: add(this); } }; - static bool review_actor_params(const actor_testcase id, - actor_params ¶ms); + static bool review_actor_params(const actor_testcase id, actor_params ¶ms, + const unsigned space_id); static testcase *create_actor(const actor_config &config, const mdbx_pid_t pid); }; @@ -301,8 +301,9 @@ public: memset(&last, 0, sizeof(last)); } - static bool review_params(actor_params ¶ms) { + static bool review_params(actor_params ¶ms, unsigned space_id) { // silently fix key/data length for fixed-length modes + params.prng_seed += bleach32(space_id); if ((params.table_flags & MDBX_INTEGERKEY) && params.keylen_min != params.keylen_max) params.keylen_min = params.keylen_max; diff --git a/test/ttl.c++ b/test/ttl.c++ index a7049022..b3839357 100644 --- a/test/ttl.c++ +++ b/test/ttl.c++ @@ -119,9 +119,8 @@ bool testcase_ttl::run() { return false; } - uint64_t seed = - prng64_map2_white(config.params.keygen.seed) + config.actor_id; - keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */); + uint64_t seed = prng64_map2_white(prng_state) + config.space_id; + keyvalue_maker.setup(config.params, 0 /* thread_number */); key = keygen::alloc(config.params.keylen_max); data = keygen::alloc(config.params.datalen_max); const MDBX_put_flags_t insert_flags = diff --git a/test/utils.c++ b/test/utils.c++ index 71d56eb8..399ea472 100644 --- a/test/utils.c++ +++ b/test/utils.c++ @@ -136,7 +136,7 @@ void prng_fill(uint64_t &state, void *ptr, size_t bytes) { } } -static __thread uint64_t prng_state; +/* __thread */ uint64_t prng_state; void prng_seed(uint64_t seed) { prng_state = bleach64(seed); } diff --git a/test/utils.h++ b/test/utils.h++ index 4e91226d..f8083437 100644 --- a/test/utils.h++ +++ b/test/utils.h++ @@ -346,6 +346,7 @@ uint64_t prng64_white(uint64_t &state); uint32_t prng32(uint64_t &state); void prng_fill(uint64_t &state, void *ptr, size_t bytes); +extern uint64_t prng_state; void prng_seed(uint64_t seed); uint32_t prng32(void); uint64_t prng64(void);