mdbx-tests: переделка seed/salt ГПСЧ для более удобного контроля и воспроизведения тестов.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-01-09 20:44:44 +03:00
parent a994a9bbcc
commit 3c60e1e94c
5 changed files with 6 additions and 3 deletions

View File

@ -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 &params, unsigned &last_space_id) {

View File

@ -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++;

View File

@ -263,8 +263,8 @@ public:
}
static bool review_params(actor_params &params, 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)

View File

@ -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); }

View File

@ -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);