mdbx-tests: кратное сокращение итераций тестов в зависимости от конфигурации Valgrind/Debug/CI (backport).

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-03-20 01:58:02 +03:00
parent 3a0dbee58c
commit 3c3628c798
5 changed files with 74 additions and 22 deletions

View File

@ -300,10 +300,10 @@ else()
endif() endif()
if(MDBX_BUILD_CXX) if(MDBX_BUILD_CXX)
if(NOT WIN32 OR NOT MDBX_CXX_STANDARD LESS 17) if(NOT WIN32 OR NOT MDBX_CXX_STANDARD LESS 17)
add_extra_test(cursor_closing) add_extra_test(cursor_closing TIMEOUT 10800)
add_extra_test(early_close_dbi) add_extra_test(early_close_dbi)
add_extra_test(maindb_ordinal) add_extra_test(maindb_ordinal)
add_extra_test(dupfix_multiple) add_extra_test(dupfix_multiple TIMEOUT 10800)
add_extra_test(doubtless_positioning TIMEOUT 10800) add_extra_test(doubtless_positioning TIMEOUT 10800)
add_extra_test(crunched_delete TIMEOUT 10800) add_extra_test(crunched_delete TIMEOUT 10800)
add_extra_test(dbi) add_extra_test(dbi)

View File

@ -5,13 +5,21 @@
#include <random> #include <random>
#include <vector> #include <vector>
#if MDBX_DEBUG || !defined(NDEBUG) || defined(__APPLE__) || defined(_WIN32) #if defined(ENABLE_MEMCHECK) || defined(MDBX_CI)
#define NN 1024 #if MDBX_DEBUG || !defined(NDEBUG)
#elif UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul #define RELIEF_FACTOR 16
#define NN 4096
#else #else
#define NN 2048 #define RELIEF_FACTOR 8
#endif #endif
#elif MDBX_DEBUG || !defined(NDEBUG) || defined(__APPLE__) || defined(_WIN32)
#define RELIEF_FACTOR 4
#elif UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul
#define RELIEF_FACTOR 2
#else
#define RELIEF_FACTOR 1
#endif
#define NN (2048 / RELIEF_FACTOR)
std::string format_va(const char *fmt, va_list ap) { std::string format_va(const char *fmt, va_list ap) {
va_list ones; va_list ones;

View File

@ -9,6 +9,22 @@
#include <thread> #include <thread>
#endif #endif
#if defined(ENABLE_MEMCHECK) || defined(MDBX_CI)
#if MDBX_DEBUG || !defined(NDEBUG)
#define RELIEF_FACTOR 16
#else
#define RELIEF_FACTOR 8
#endif
#elif MDBX_DEBUG || !defined(NDEBUG) || defined(__APPLE__) || defined(_WIN32)
#define RELIEF_FACTOR 4
#elif UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul
#define RELIEF_FACTOR 2
#else
#define RELIEF_FACTOR 1
#endif
#define NN (1000 / RELIEF_FACTOR)
static void logger_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg, static void logger_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg,
unsigned length) noexcept { unsigned length) noexcept {
(void)length; (void)length;
@ -113,10 +129,10 @@ void case1_shuffle_pool(std::vector<MDBX_cursor *> &pool) {
void case1_read_pool(std::vector<MDBX_cursor *> &pool) { void case1_read_pool(std::vector<MDBX_cursor *> &pool) {
for (auto c : pool) for (auto c : pool)
if (flipcoin()) if (flipcoin())
mdbx::cursor(c).find_multivalue(mdbx::slice::wrap(prng(1000)), mdbx::slice::wrap(prng(1000)), false); mdbx::cursor(c).find_multivalue(mdbx::slice::wrap(prng(NN)), mdbx::slice::wrap(prng(NN)), false);
for (auto c : pool) for (auto c : pool)
if (flipcoin()) if (flipcoin())
mdbx::cursor(c).find_multivalue(mdbx::slice::wrap(prng(1000)), mdbx::slice::wrap(prng(1000)), false); mdbx::cursor(c).find_multivalue(mdbx::slice::wrap(prng(NN)), mdbx::slice::wrap(prng(NN)), false);
} }
MDBX_cursor *case1_try_unbind(MDBX_cursor *cursor) { MDBX_cursor *case1_try_unbind(MDBX_cursor *cursor) {
@ -224,9 +240,9 @@ void case1_write_cycle(mdbx::txn_managed txn, std::deque<mdbx::map_handle> &dbi,
pre.unbind(); pre.unbind();
if (!pre.txn()) if (!pre.txn())
pre.bind(txn, dbi[prng(dbi.size())]); pre.bind(txn, dbi[prng(dbi.size())]);
for (auto i = 0; i < 1000; ++i) { for (auto i = 0; i < NN; ++i) {
auto k = mdbx::default_buffer::wrap(prng(1000)); auto k = mdbx::default_buffer::wrap(prng(NN));
auto v = mdbx::default_buffer::wrap(prng(1000)); auto v = mdbx::default_buffer::wrap(prng(NN));
if (pre.find_multivalue(k, v, false)) if (pre.find_multivalue(k, v, false))
pre.erase(); pre.erase();
else else
@ -246,8 +262,8 @@ void case1_write_cycle(mdbx::txn_managed txn, std::deque<mdbx::map_handle> &dbi,
bool case1_thread(mdbx::env env, std::deque<mdbx::map_handle> dbi, mdbx::cursor pre) { bool case1_thread(mdbx::env env, std::deque<mdbx::map_handle> dbi, mdbx::cursor pre) {
salt = size_t(std::chrono::high_resolution_clock::now().time_since_epoch().count()); salt = size_t(std::chrono::high_resolution_clock::now().time_since_epoch().count());
std::vector<MDBX_cursor *> pool; std::vector<MDBX_cursor *> pool;
for (auto loop = 0; loop < 333; ++loop) { for (auto loop = 0; loop < 333 / RELIEF_FACTOR; ++loop) {
for (auto read = 0; read < 333; ++read) { for (auto read = 0; read < 333 / RELIEF_FACTOR; ++read) {
auto txn = env.start_read(); auto txn = env.start_read();
case1_read_cycle(txn, dbi, pool, pre); case1_read_cycle(txn, dbi, pool, pre);
if (flipcoin()) if (flipcoin())
@ -280,8 +296,8 @@ bool case1(mdbx::env env) {
auto txn = env.start_write(); auto txn = env.start_write();
auto table = txn.create_map(std::to_string(t), mdbx::key_mode::ordinal, mdbx::value_mode::multi_samelength); auto table = txn.create_map(std::to_string(t), mdbx::key_mode::ordinal, mdbx::value_mode::multi_samelength);
auto cursor = txn.open_cursor(table); auto cursor = txn.open_cursor(table);
for (size_t i = 0; i < 10000; ++i) for (size_t i = 0; i < NN * 11; ++i)
cursor.upsert(mdbx::default_buffer::wrap(prng(1000)), mdbx::default_buffer::wrap(prng(1000))); cursor.upsert(mdbx::default_buffer::wrap(prng(NN)), mdbx::default_buffer::wrap(prng(NN)));
txn.commit(); txn.commit();
cursors.push_back(std::move(cursor)); cursors.push_back(std::move(cursor));

View File

@ -5,6 +5,20 @@
#include <chrono> #include <chrono>
#include <iostream> #include <iostream>
#if defined(ENABLE_MEMCHECK) || defined(MDBX_CI)
#if MDBX_DEBUG || !defined(NDEBUG)
#define RELIEF_FACTOR 16
#else
#define RELIEF_FACTOR 8
#endif
#elif MDBX_DEBUG || !defined(NDEBUG) || defined(__APPLE__) || defined(_WIN32)
#define RELIEF_FACTOR 4
#elif UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul
#define RELIEF_FACTOR 2
#else
#define RELIEF_FACTOR 1
#endif
using buffer = mdbx::default_buffer; using buffer = mdbx::default_buffer;
bool case1_ordering(mdbx::env env) { bool case1_ordering(mdbx::env env) {
@ -224,7 +238,7 @@ static size_t prng() {
static inline size_t prng(size_t range) { return prng() % range; } static inline size_t prng(size_t range) { return prng() % range; }
static mdbx::default_buffer_pair prng_kv(size_t n, size_t space) { static mdbx::default_buffer_pair prng_kv(size_t n, size_t space) {
space = (space + !space) * 1024 * 32; space = (space + !space) * 1024 * 32 / RELIEF_FACTOR;
const size_t w = (n ^ 1455614549) * 1664525 + 1013904223; const size_t w = (n ^ 1455614549) * 1664525 + 1013904223;
const size_t k = (prng(42 + w % space) ^ 1725278851) * 433750991; const size_t k = (prng(42 + w % space) ^ 1725278851) * 433750991;
const size_t v = prng(); const size_t v = prng();
@ -235,11 +249,11 @@ bool case3_put_a_lot(mdbx::env env) {
salt = size_t(std::chrono::high_resolution_clock::now().time_since_epoch().count()); salt = size_t(std::chrono::high_resolution_clock::now().time_since_epoch().count());
auto txn = env.start_write(); auto txn = env.start_write();
auto map = txn.create_map("case3", mdbx::key_mode::ordinal, mdbx::value_mode::multi_ordinal); auto map = txn.create_map("case3", mdbx::key_mode::ordinal, mdbx::value_mode::multi_ordinal);
for (size_t n = 0; n < 5555555; ++n) for (size_t n = 0; n < 5555555 / RELIEF_FACTOR; ++n)
txn.upsert(map, prng_kv(n, 1)); txn.upsert(map, prng_kv(n, 1));
txn.commit(); txn.commit();
for (size_t t = 0; t < 555; ++t) { for (size_t t = 0; t < 555 / RELIEF_FACTOR; ++t) {
txn = env.start_write(); txn = env.start_write();
auto cursor = txn.open_cursor(map); auto cursor = txn.open_cursor(map);
for (size_t n = 0; n < 111; ++n) { for (size_t n = 0; n < 111; ++n) {
@ -247,7 +261,7 @@ bool case3_put_a_lot(mdbx::env env) {
const auto r = 1 + prng(3); const auto r = 1 + prng(3);
if (r & 1) { if (r & 1) {
const auto k = prng_kv(n + t, 2).key; const auto k = prng_kv(n + t, 2).key;
for (size_t i = prng(42 + prng(111) * prng(111)); i > 0; --i) for (size_t i = prng(42 + prng(111) * prng(111 / RELIEF_FACTOR)); i > 0; --i)
v.push_back(prng()); v.push_back(prng());
txn.put_multiple_samelength(map, k, v, mdbx::upsert); txn.put_multiple_samelength(map, k, v, mdbx::upsert);
} }
@ -255,7 +269,7 @@ bool case3_put_a_lot(mdbx::env env) {
const auto k = prng_kv(n + t, 2).key; const auto k = prng_kv(n + t, 2).key;
if (cursor.seek(k)) { if (cursor.seek(k)) {
v.clear(); v.clear();
for (size_t i = prng(42 + prng(111) * prng(111)); i > 0; --i) for (size_t i = prng(42 + prng(111) * prng(111 / RELIEF_FACTOR)); i > 0; --i)
v.push_back(prng()); v.push_back(prng());
cursor.put_multiple_samelength(k, v, mdbx::upsert); cursor.put_multiple_samelength(k, v, mdbx::upsert);
} }

View File

@ -3,6 +3,20 @@
#include <iostream> #include <iostream>
#if defined(ENABLE_MEMCHECK) || defined(MDBX_CI)
#if MDBX_DEBUG || !defined(NDEBUG)
#define RELIEF_FACTOR 16
#else
#define RELIEF_FACTOR 8
#endif
#elif MDBX_DEBUG || !defined(NDEBUG) || defined(__APPLE__) || defined(_WIN32)
#define RELIEF_FACTOR 4
#elif UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul
#define RELIEF_FACTOR 2
#else
#define RELIEF_FACTOR 1
#endif
#if !defined(__cpp_lib_latch) && __cpp_lib_latch < 201907L #if !defined(__cpp_lib_latch) && __cpp_lib_latch < 201907L
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
@ -295,7 +309,7 @@ bool case2(const mdbx::path &path, bool no_sticky_threads) {
for (size_t n = 0; n < 8; ++n) for (size_t n = 0; n < 8; ++n)
l.push_back(std::thread([&]() { l.push_back(std::thread([&]() {
s.wait(); s.wait();
for (size_t i = 0; i < 1000000; ++i) { for (size_t i = 0; i < 1000000 / RELIEF_FACTOR; ++i) {
auto txn = env.start_read(); auto txn = env.start_read();
txn.abort(); txn.abort();
} }