mdbx-test: auto-reducing nops for nested and ttl testcases.

Change-Id: Ie060c580e87becbc033611e00532449522f3adbe
This commit is contained in:
Leonid Yuriev 2020-05-19 14:18:26 +03:00
parent 51a016245a
commit 2e7e1079c4
4 changed files with 47 additions and 4 deletions

View File

@ -24,6 +24,20 @@ bool testcase_nested::setup() {
return false; return false;
} }
constexpr unsigned reduce_nops_threshold = 5000;
if (nops_target > reduce_nops_threshold) {
unsigned batching = config.params.batch_read + config.params.batch_write;
unsigned reduce_nops =
reduce_nops_threshold +
5 * unsigned(sqrt(nops_target - reduce_nops_threshold +
nops_target / (batching ? batching : 1)));
if (reduce_nops >= config.signal_nops) {
log_notice("nested: return target-nops from %u to %u", nops_target,
reduce_nops);
nops_target = reduce_nops;
}
}
keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */); keyvalue_maker.setup(config.params, config.actor_id, 0 /* thread_number */);
key = keygen::alloc(config.params.keylen_max); key = keygen::alloc(config.params.keylen_max);
data = keygen::alloc(config.params.datalen_max); data = keygen::alloc(config.params.datalen_max);
@ -83,6 +97,7 @@ void testcase_nested::push_txn() {
std::swap(txn_guard, std::get<0>(stack.top())); std::swap(txn_guard, std::get<0>(stack.top()));
log_verbose("begin level#%zu txn #%" PRIu64 ", flags 0x%x, serial %" PRIu64, log_verbose("begin level#%zu txn #%" PRIu64 ", flags 0x%x, serial %" PRIu64,
stack.size(), mdbx_txn_id(txn), flags, serial); stack.size(), mdbx_txn_id(txn), flags, serial);
report(1);
} }
bool testcase_nested::pop_txn(bool abort) { bool testcase_nested::pop_txn(bool abort) {
@ -122,6 +137,7 @@ bool testcase_nested::pop_txn(bool abort) {
std::swap(speculum, std::get<3>(stack.top())); std::swap(speculum, std::get<3>(stack.top()));
} }
stack.pop(); stack.pop();
report(1);
return should_continue; return should_continue;
} }
@ -171,6 +187,7 @@ bool testcase_nested::trim_tail(unsigned window_width) {
if (unlikely(!keyvalue_maker.increment(tail_serial, 1))) if (unlikely(!keyvalue_maker.increment(tail_serial, 1)))
failure("nested: unexpected key-space overflow on the tail"); failure("nested: unexpected key-space overflow on the tail");
} }
report(1);
} }
} else if (!fifo.empty()) { } else if (!fifo.empty()) {
log_verbose("nested: purge state %" PRIu64 " - %" PRIu64 ", fifo-items %zu", log_verbose("nested: purge state %" PRIu64 " - %" PRIu64 ", fifo-items %zu",
@ -178,6 +195,7 @@ bool testcase_nested::trim_tail(unsigned window_width) {
fifo.size()); fifo.size());
db_table_clear(dbi, txn_guard.get()); db_table_clear(dbi, txn_guard.get());
fifo.clear(); fifo.clear();
report(1);
} }
return true; return true;
} }
@ -208,6 +226,7 @@ retry:
} }
} }
report(1);
return true; return true;
} }
@ -276,8 +295,6 @@ bool testcase_nested::run() {
log_notice("nested: bailout after head-grow"); log_notice("nested: bailout after head-grow");
return false; return false;
} }
report(1);
} }
while (!stack.empty()) while (!stack.empty())

View File

@ -398,8 +398,7 @@ bool testcase::should_continue(bool check_timeout_only) const {
result = false; result = false;
} }
if (!check_timeout_only && config.params.test_nops && if (!check_timeout_only && nops_target && nops_completed >= nops_target)
nops_completed >= config.params.test_nops)
result = false; result = false;
if (result) if (result)

View File

@ -148,6 +148,7 @@ protected:
bool signalled{false}; bool signalled{false};
bool need_speculum_assign{false}; bool need_speculum_assign{false};
unsigned nops_target{config.params.test_nops};
size_t nops_completed{0}; size_t nops_completed{0};
chrono::time start_timestamp; chrono::time start_timestamp;
keygen::buffer key; keygen::buffer key;
@ -229,10 +230,13 @@ public:
}; };
class testcase_ttl : public testcase { class testcase_ttl : public testcase {
using inherited = testcase;
public: public:
testcase_ttl(const actor_config &config, const mdbx_pid_t pid) testcase_ttl(const actor_config &config, const mdbx_pid_t pid)
: testcase(config, pid) {} : testcase(config, pid) {}
bool run() override; bool run() override;
bool setup() override;
}; };
class testcase_hill : public testcase { class testcase_hill : public testcase {

View File

@ -16,6 +16,27 @@
#include <cmath> #include <cmath>
#include <deque> #include <deque>
bool testcase_ttl::setup() {
if (!inherited::setup())
return false;
constexpr unsigned reduce_nops_threshold = 10000;
if (nops_target > reduce_nops_threshold) {
unsigned batching = config.params.batch_read + config.params.batch_write;
unsigned reduce_nops =
reduce_nops_threshold + (nops_target - reduce_nops_threshold +
nops_target / (batching ? batching : 1)) /
5;
if (reduce_nops >= config.signal_nops) {
log_notice("ttl: return target-nops from %u to %u", nops_target,
reduce_nops);
nops_target = reduce_nops;
}
}
return true;
}
static unsigned edge2window(uint64_t edge, unsigned window_max) { static unsigned edge2window(uint64_t edge, unsigned window_max) {
const double rnd = u64_to_double1(bleach64(edge)); const double rnd = u64_to_double1(bleach64(edge));
const unsigned window = window_max - std::lrint(std::pow(window_max, rnd)); const unsigned window = window_max - std::lrint(std::pow(window_max, rnd));
@ -108,11 +129,13 @@ bool testcase_ttl::run() {
if (unlikely(!keyvalue_maker.increment(tail_serial, 1))) if (unlikely(!keyvalue_maker.increment(tail_serial, 1)))
failure("ttl: unexpected key-space overflow on the tail"); failure("ttl: unexpected key-space overflow on the tail");
} }
report(1);
} }
} else { } else {
log_trace("ttl: purge state"); log_trace("ttl: purge state");
db_table_clear(dbi); db_table_clear(dbi);
fifo.clear(); fifo.clear();
report(1);
} }
err = breakable_restart(); err = breakable_restart();