From 3c3628c7989f75a343e48d50c868e2f60c3220d1 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, 20 Mar 2025 01:58:02 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-tests:=20=D0=BA=D1=80=D0=B0=D1=82=D0=BD?= =?UTF-8?q?=D0=BE=D0=B5=20=D1=81=D0=BE=D0=BA=D1=80=D0=B0=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D1=82=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= =?UTF-8?q?=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2=20=D0=B2=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D0=BE?= =?UTF-8?q?=D1=82=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20Valgrind/Debug/CI=20(backport).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/CMakeLists.txt | 4 ++-- test/extra/crunched_delete.c++ | 18 +++++++++++++----- test/extra/cursor_closing.c++ | 34 +++++++++++++++++++++++++--------- test/extra/dupfix_multiple.c++ | 24 +++++++++++++++++++----- test/extra/txn.c++ | 16 +++++++++++++++- 5 files changed, 74 insertions(+), 22 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d4dfc086..dda4a909 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -300,10 +300,10 @@ else() endif() if(MDBX_BUILD_CXX) 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(maindb_ordinal) - add_extra_test(dupfix_multiple) + add_extra_test(dupfix_multiple TIMEOUT 10800) add_extra_test(doubtless_positioning TIMEOUT 10800) add_extra_test(crunched_delete TIMEOUT 10800) add_extra_test(dbi) diff --git a/test/extra/crunched_delete.c++ b/test/extra/crunched_delete.c++ index af2e6fad..4b740664 100644 --- a/test/extra/crunched_delete.c++ +++ b/test/extra/crunched_delete.c++ @@ -5,13 +5,21 @@ #include #include -#if MDBX_DEBUG || !defined(NDEBUG) || defined(__APPLE__) || defined(_WIN32) -#define NN 1024 -#elif UINTPTR_MAX > 0xffffFFFFul || ULONG_MAX > 0xffffFFFFul -#define NN 4096 +#if defined(ENABLE_MEMCHECK) || defined(MDBX_CI) +#if MDBX_DEBUG || !defined(NDEBUG) +#define RELIEF_FACTOR 16 #else -#define NN 2048 +#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 (2048 / RELIEF_FACTOR) std::string format_va(const char *fmt, va_list ap) { va_list ones; diff --git a/test/extra/cursor_closing.c++ b/test/extra/cursor_closing.c++ index 5f575c89..24633560 100644 --- a/test/extra/cursor_closing.c++ +++ b/test/extra/cursor_closing.c++ @@ -9,6 +9,22 @@ #include #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, unsigned length) noexcept { (void)length; @@ -113,10 +129,10 @@ void case1_shuffle_pool(std::vector &pool) { void case1_read_pool(std::vector &pool) { for (auto c : pool) 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) 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) { @@ -224,9 +240,9 @@ void case1_write_cycle(mdbx::txn_managed txn, std::deque &dbi, pre.unbind(); if (!pre.txn()) pre.bind(txn, dbi[prng(dbi.size())]); - for (auto i = 0; i < 1000; ++i) { - auto k = mdbx::default_buffer::wrap(prng(1000)); - auto v = mdbx::default_buffer::wrap(prng(1000)); + for (auto i = 0; i < NN; ++i) { + auto k = mdbx::default_buffer::wrap(prng(NN)); + auto v = mdbx::default_buffer::wrap(prng(NN)); if (pre.find_multivalue(k, v, false)) pre.erase(); else @@ -246,8 +262,8 @@ void case1_write_cycle(mdbx::txn_managed txn, std::deque &dbi, bool case1_thread(mdbx::env env, std::deque dbi, mdbx::cursor pre) { salt = size_t(std::chrono::high_resolution_clock::now().time_since_epoch().count()); std::vector pool; - for (auto loop = 0; loop < 333; ++loop) { - for (auto read = 0; read < 333; ++read) { + for (auto loop = 0; loop < 333 / RELIEF_FACTOR; ++loop) { + for (auto read = 0; read < 333 / RELIEF_FACTOR; ++read) { auto txn = env.start_read(); case1_read_cycle(txn, dbi, pool, pre); if (flipcoin()) @@ -280,8 +296,8 @@ bool case1(mdbx::env env) { auto txn = env.start_write(); auto table = txn.create_map(std::to_string(t), mdbx::key_mode::ordinal, mdbx::value_mode::multi_samelength); auto cursor = txn.open_cursor(table); - for (size_t i = 0; i < 10000; ++i) - cursor.upsert(mdbx::default_buffer::wrap(prng(1000)), mdbx::default_buffer::wrap(prng(1000))); + for (size_t i = 0; i < NN * 11; ++i) + cursor.upsert(mdbx::default_buffer::wrap(prng(NN)), mdbx::default_buffer::wrap(prng(NN))); txn.commit(); cursors.push_back(std::move(cursor)); diff --git a/test/extra/dupfix_multiple.c++ b/test/extra/dupfix_multiple.c++ index f4aa94be..a18ebfc8 100644 --- a/test/extra/dupfix_multiple.c++ +++ b/test/extra/dupfix_multiple.c++ @@ -5,6 +5,20 @@ #include #include +#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; 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 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 k = (prng(42 + w % space) ^ 1725278851) * 433750991; 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()); auto txn = env.start_write(); 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.commit(); - for (size_t t = 0; t < 555; ++t) { + for (size_t t = 0; t < 555 / RELIEF_FACTOR; ++t) { txn = env.start_write(); auto cursor = txn.open_cursor(map); 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); if (r & 1) { 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()); 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; if (cursor.seek(k)) { 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()); cursor.put_multiple_samelength(k, v, mdbx::upsert); } diff --git a/test/extra/txn.c++ b/test/extra/txn.c++ index 583328cf..40f9ab0b 100644 --- a/test/extra/txn.c++ +++ b/test/extra/txn.c++ @@ -3,6 +3,20 @@ #include +#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 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) l.push_back(std::thread([&]() { 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(); txn.abort(); }