From 3c60e1e94c127843ffe8dffadab6c2f4a2bd72f9 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: Thu, 9 Jan 2025 20:44:44 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-tests:=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=BA=D0=B0=20seed/salt=20=D0=93=D0=9F=D0=A1=D0=A7?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D1=83?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D1=8F=20=D0=B8=20=D0=B2=D0=BE=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B8=D0=B7=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/cases.c++ | 1 + test/test.c++ | 2 +- test/test.h++ | 2 +- test/utils.c++ | 3 ++- test/utils.h++ | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/cases.c++ b/test/cases.c++ index fdb99485..06a371a6 100644 --- a/test/cases.c++ +++ b/test/cases.c++ @@ -72,6 +72,7 @@ void configure_actor(unsigned &last_space_id, const actor_testcase testcase, con log_trace("configure_actor: space %lu for %s", space_id, testcase2str(testcase)); global::actors.emplace_back(actor_config(testcase, params, unsigned(space_id), wait4id)); global::databases.insert(params.pathname_db); + params.prng_seed += bleach64(space_id); } void testcase_setup(const char *casename, const actor_params ¶ms, unsigned &last_space_id) { diff --git a/test/test.c++ b/test/test.c++ index 1d8db898..c13466e5 100644 --- a/test/test.c++ +++ b/test/test.c++ @@ -770,7 +770,7 @@ static bool execute_thunk(const actor_config *const_config, const mdbx_pid_t pid size_t iter = 0; do { if (iter) { - prng_seed(config.params.prng_seed += INT32_C(0xA4F4D37B)); + prng_salt(iter); log_verbose("turn PRNG to %u", config.params.prng_seed); } iter++; diff --git a/test/test.h++ b/test/test.h++ index 861429ff..876b83cc 100644 --- a/test/test.h++ +++ b/test/test.h++ @@ -263,8 +263,8 @@ public: } static bool review_params(actor_params ¶ms, unsigned space_id) { + (void)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; if ((params.table_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED)) && params.datalen_min != params.datalen_max) diff --git a/test/utils.c++ b/test/utils.c++ index 442e4a21..884fd844 100644 --- a/test/utils.c++ +++ b/test/utils.c++ @@ -124,7 +124,8 @@ void prng_fill(uint64_t &state, void *ptr, size_t bytes) { /* __thread */ uint64_t prng_state; -void prng_seed(uint64_t seed) { prng_state = bleach64(seed); } +void prng_seed(uint64_t seed) { prng_state = seed; } +void prng_salt(unsigned salt) { prng_state += bleach32(salt) * UINT64_C(0xD14A2783862DAB); } uint32_t prng32(void) { return prng32_white(prng_state); } diff --git a/test/utils.h++ b/test/utils.h++ index caa34049..2abc393b 100644 --- a/test/utils.h++ +++ b/test/utils.h++ @@ -313,6 +313,7 @@ void prng_fill(uint64_t &state, void *ptr, size_t bytes); extern uint64_t prng_state; void prng_seed(uint64_t seed); +void prng_salt(unsigned salt); uint32_t prng32(void); uint64_t prng64(void); void prng_fill(void *ptr, size_t bytes);