mirror of
https://github.com/isar/libmdbx.git
synced 2025-03-29 13:12:58 +08:00
mdbx-tests: кратное сокращение итераций тестов в зависимости от конфигурации Valgrind/Debug/CI (backport).
This commit is contained in:
parent
3a0dbee58c
commit
3c3628c798
@ -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)
|
||||
|
@ -5,13 +5,21 @@
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
#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;
|
||||
|
@ -9,6 +9,22 @@
|
||||
#include <thread>
|
||||
#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<MDBX_cursor *> &pool) {
|
||||
void case1_read_pool(std::vector<MDBX_cursor *> &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<mdbx::map_handle> &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<mdbx::map_handle> &dbi,
|
||||
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());
|
||||
std::vector<MDBX_cursor *> 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));
|
||||
|
@ -5,6 +5,20 @@
|
||||
#include <chrono>
|
||||
#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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -3,6 +3,20 @@
|
||||
|
||||
#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
|
||||
|
||||
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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user