libmdbx (2022-05-10 ... 2022-12-21)
mdbx_dbi_sequence() - между открытиями не обнуляется ?
mdbx_dbi_open( txn, "my_submDB-1" ...)
mdbx_dbi_open( txn, "my_submDB-2" ...)
что-то не соображу , есть ли штатный механизьм получить список этих subDB ?
std::filesystem support check and the search for the necessary library were failed, since selected iOS/OSX target version don't support it.make -k or similar, and then put log file here.CMakeList.txt files an addition of the -Werror option.
mdbx_setup_debug() = https://libmdbx.dqdkfa.ru/groupcdebug.html#gae5f003fad215cdd8253ef43b55a02ae00.11.7 в коде было определение _FILE_OFFSET_BITS=64 что из-за баго-фичи Android/Bionic приводило к устойчивому EINVAL на 32-битных x86 сборках Андроид (см. https://gitflic.ru/project/erthink/libmdbx/issue/2)..lck-файла, т.е. видимо лог совсем не полный.
master branch.
(ms_branch_pages + ms_leaf_pages) * ms_psize be the size of the database?
mdbx_stat), проверять БД (посредством mdbx_chk) и выяснять что пошло не так...
LIBMDBX_EXPORTS и получить желаемый эффект.Устанавливаем max_dbs = 1024
mdbx_dbi_open: (-30791) MDBX_DBS_FULL: Too many DBI-handles (maxdbs reached)
Подскажите, плиз, что проверить ?
max_dbs = 1024 выполняется до открытия БД и результат этой операции MDBX_SUCCESS ?
if ( MDBX_SUCCESS != (l_rc = mdbx_env_create(&s_mdbx_env)) )
return log_it(L_CRITICAL, "mdbx_env_create: (%d) %s", l_rc, mdbx_strerror(l_rc)), -ENOENT;
log_it(L_NOTICE, "Set maximum number of local groups: %d", DAP_DB$K_MAXGROUPS);
assert ( !mdbx_env_set_maxdbs (s_mdbx_env, DAP_DB$K_MAXGROUPS) ); /* Set maximum number of the file-tables (MDBX subDB)
according to number of supported groups */
/* We set "unlim" for all MDBX characteristics at the moment */
if ( MDBX_SUCCESS != (l_rc = mdbx_env_set_geometry(s_mdbx_env, -1, -1, l_upper_limit_of_db_size, -1, -1, -1)) )
return log_it (L_CRITICAL, "mdbx_env_set_geometry (%s): (%d) %s", s_db_path, l_rc, mdbx_strerror(l_rc)), -EINVAL;
if ( MDBX_SUCCESS != (l_rc = mdbx_env_open(s_mdbx_env, s_db_path, MDBX_CREATE | MDBX_COALESCE | MDBX_LIFORECLAIM, 0664)) )
return log_it (L_CRITICAL, "mdbx_env_open (%s): (%d) %s", s_db_path, l_rc, mdbx_strerror(l_rc)), -EINVAL;
mdbx_dbi_open() и/или mdbx_dbi_open_ex() чтобы видеть сколько dbi-хендлов открывается и с какими значениями.MDBX_DBS_FULL (всего два таких места, оба в функции db_open()), а после поковыряться самостоятельно или показать мне содержание кадров стека и основных объектов (env, txn).make --keep-going &>log.txt, а потом приложите log.txt к сообщению здесь.make V=1 for verbose.make options to listing available build options.make help to listing available targets.make - то нет никаких ошибок.
-k из-под cmake.cmake -build . -- -k &> log.txt
ninja -j 1 -k 0 &>log.txt
&>log.txt или как-то иначе?
&>.
--keep-going при сборке.-Werror из опций (как вы делали раньше) и собрать с перенаправлением в файл.-Wshorten-64-to-32.
__thread).warning: (x86_64) failed to insert symbol '__ZZ13test_strerroriE3buf' in the debug map.
warning: (x86_64) failed to insert symbol '__ZL10prng_state' in the debug map.
-lck file on the read-only volume.github.com/torquem-ch/mdbx-go/mdbx which produces the following error:
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x40d27f]
horizon_osm |
runtime stack:
runtime.throw({0xceb4c8?, 0x7f75d2007a16?})
/usr/lib/go/src/runtime/panic.go:992 +0x71
runtime.sigpanic()
/usr/lib/go/src/runtime/signal_unix.go:802 +0x3a9
horizon_osm |
goroutine 1 [syscall]:
runtime.cgocall(0xa7bc50, 0xc0000f9bb8)
/usr/lib/go/src/runtime/cgocall.go:157 +0x5c fp=0xc0000f9b90 sp=0xc0000f9b58 pc=0x4293fc
github.com/torquem-ch/mdbx-go/mdbx._Cfunc_mdbx_env_open(0x7f75d207e8c0, 0x7f75d207a910, 0x2a24000, 0x124)
_cgo_gotypes.go:708 +0x4c fp=0xc0000f9bb8 sp=0xc0000f9b90 pc=0x5a2bec
github.com/torquem-ch/mdbx-go/mdbx.(*Env).Open.func2(0x7f75d207a910?, 0
x20?, 0x2824000, 0x0?)
/go/pkg/mod/github.com/torquem-ch/mdbx-go@v0.23.2/mdbx/env.go:153 +0x74 fp=0xc0000f9c00 sp=0xc0000f9bb8 pc=0x5a7534
github.com/torquem-ch/mdbx-go/mdbx.(*Env).Open(0x497e46?, {0x7fff6849ae8d?, 0x0?}, 0x0?, 0x80?)
MDBX_EXCLUSIVE | MDBX_RDONLY to open DB on a read-only media/volume.devel branch = https://gitflic.ru/project/erthink/libmdbx/commit/e795fe7c3ee093e1188095d9006aa707001ff174MDBX_NOSUBDIR option the name of a DB-file is arbitrary (defined by application code).
$TMP_DIR$TMP_DIR/my.db with the flag NoSubdir$TMP_DIR/my.db with the flags NoSubdir|Exclusive|Readonlypanic: mdbx_env_open: permission denied
make./mdbx_chk -v path-to-your-db.
/code/mi/play/mdbx-bug/libmdbx devel ❯ ./mdbx_chk /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db
mdbx_chk v0.11.7-50-g77f56541 (2022-06-04T02:08:24+03:00, T-c1bcf1b3ab87e8b856175c4bb9ad5d2a5778aad7)
Running for /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db in 'read-only' mode...
! mdbx_env_open() failed, error 13 Permission denied
/code/mi/play/mdbx-bug/libmdbx devel ❯ chmod 777 /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/
/code/mi/play/mdbx-bug/libmdbx devel ❯ ./mdbx_chk /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db
mdbx_chk v0.11.7-50-g77f56541 (2022-06-04T02:08:24+03:00, T-c1bcf1b3ab87e8b856175c4bb9ad5d2a5778aad7)
Running for /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db in 'read-only' mode...
Traversal b-tree by txn#4...
Iterating DBIs...
No error is detected, elapsed 0.006 seconds
executable bit for the owner (and only the owner) resolves the issue:
/code/mi/pla/mdbx-bug/libmdbx devel ❯ chmod 444 /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/
/code/mi/play/mdbx-bug/libmdbx devel ❯ ./mdbx_chk -v /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db
mdbx_chk v0.11.7-50-g77f56541 (2022-06-04T02:08:24+03:00, T-c1bcf1b3ab87e8b856175c4bb9ad5d2a5778aad7)
Running for /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db in 'read-only' mode...
! mdbx_env_open() failed, error 13 Permission denied
/code/mi/play/mdbx-bug/libmdbx devel ❯ chmod 544 /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/
/code/mi/play/mdbx-bug/libmdbx devel ❯ ./mdbx_chk -v /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db
mdbx_chk v0.11.7-50-g77f56541 (2022-06-04T02:08:24+03:00, T-c1bcf1b3ab87e8b856175c4bb9ad5d2a5778aad7)
Running for /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db in 'read-only' mode...
- monopolistic mode
- current boot-id b914b4228e6fc859-3142ec2a5ee24d50
- pagesize 4096 (4096 system), max keysize 1980..2022, max readers 116
- mapsize 1073741824 (1.00 Gb)
- dynamic datafile: 12288 (12.00 Kb) .. 1073741824 (1.00 Gb), +536870912 (512.00 Mb), -1073741824 (1.00 Gb)
- current datafile: 536870912 (512.00 Mb), 131072 pages
- meta-0: steady txn#4, head
- meta-1: steady txn#2, tail
- meta-2: steady txn#3, stay
- transactions: recent 4, latter reader 4, lag 0
Traversal b-tree by txn#4...
- found 'example' area
- pages: walked 5, left/unused 0
- summary: average fill 4.0%, 0 problems
Processing '@MAIN'...
- key-value kind: usual-key => single-value
- last modification txn#4
- summary: 1 records, 0 dups, 7 key's bytes, 48 data's bytes, 0 problems
Processing '@GC'...
- key-value kind: ordinal-key => single-value
- summary: 0 records, 0 dups, 0 key's bytes, 0 data's bytes, 0 problems
- space: 262144 total pages, backed 131072 (50.0%), allocated 5 (0.0%), available 262139 (100.0%)
Processing 'example'...
- key-value kind: usual-key => single-value
- last modification txn#4
- summary: 1 records, 0 dups, 5 key's bytes, 5 data's bytes, 0 problems
No error is detected, elapsed 0.004 seconds
454 and 445 don't work but 544 does 🤷
444 doesn't work:
/code/mi/play/mdbx-bug/libmdbx devel ❯ chmod 444 /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/
/code/mi/play/mdbx-bug/libmdbx devel ❯ sudo rm /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db-lck
/code/mi/play/mdbx-bug/libmdbx devel ❯ ./mdbx_chk -v /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db
mdbx_chk v0.11.7-50-g77f56541 (2022-06-04T02:08:24+03:00, T-c1bcf1b3ab87e8b856175c4bb9ad5d2a5778aad7)
Running for /var/folders/5w/xzyyzb490m36my2j2w4094_m0000gn/T/mdbx3164665739/my.db in 'read-only' mode...
! mdbx_env_open() failed, error 13 Permission denied
mkdir -p /tmp/example
touch /tmp/example/file
ls -lah /tmp/example/
total 0
drwxr-xr-x 3 peter wheel 96 Jun 6 21:51 .
drwxrwxrwt 53 root wheel 1.7K Jun 6 21:51 ..
-rw-r--r-- 1 peter wheel 0 Jun 6 21:51 file
chmod 444 /tmp/example
ls -lah /tmp/example/
ls: cannot access '/tmp/example/.': Permission denied
ls: cannot access '/tmp/example/..': Permission denied
ls: cannot access '/tmp/example/file': Permission denied
total 0
d????????? ? ? ? ? ? .
d????????? ? ? ? ? ? ..
-????????? ? ? ? ? ? file
ubuntu@hetzner:~$ mkdir -p /tmp/example
ubuntu@hetzner:~$ touch /tmp/example/file
ubuntu@hetzner:~$ ls -lah /tmp/example/
total 20K
drwxrwxr-x 2 ubuntu ubuntu 4.0K Jun 6 21:59 .
drwxrwxrwt 17 root root 16K Jun 6 21:59 ..
-rw-rw-r-- 1 ubuntu ubuntu 0 Jun 6 21:59 file
ubuntu@hetzner:~$ chmod 444 /tmp/example
ubuntu@hetzner:~$ ls -lah /tmp/example/
ls: cannot access '/tmp/example/..': Permission denied
ls: cannot access '/tmp/example/.': Permission denied
ls: cannot access '/tmp/example/file': Permission denied
total 0
d????????? ? ? ? ? ? .
d????????? ? ? ? ? ? ..
-????????? ? ? ? ? ? file
master подготовлен кандидат в релизы, который намечен на 12 число. Просьба по-возможности по-тестировать.master branch. Please test it. VERIFY amalgamated sources...In file included from mdbx.c:1060:
В функции «atomic_store64»,
включённом из «mdbx_find_oldest.isra» в mdbx.c:9227:12:
mdbx.c:4320:3: ошибка: «__atomic_store_8» writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
master из https://gitflic.ru/project/erthink/libmdbx, либо подождите пару дней релиз v0.11.8
__thread, освобождалась после вызова зарегистрированных TLS-деструкторов, что соответствовало обычному/ожидаемому порядку освобождения/разрушения, обратному при выделении/создании.__thread-переменные блоки памяти освобождается до вызова зарегистрированных деструкторов, из-за чего такой деструктор в libmdbx писал в уже освобожденный регион.__thread-переменных только при отсутствии __cxa_thread_atexit()._tlv_atexit() не использовалась, ибо: (1) не имеет якоря привязки к DSO из-за чего приводит к падениям при выгрузке dso/dll, (2) отлично работал резервный механизм в libmdbx._tlv_atexit() на Darwin.
MDBX_NOTLS
1000001 to the new writeable transactions. How does this help?"
1_000_000 даёт эффект только в достаточно искусственной/редкой ситуации, когда в нескольких первых транзакциях большая БД наполняется и существенно меняется (удаляется и/или обновляется большое кол-во записей).txnid.mdbx_update_gc(), т.е. требует времени и тестирования.txnid для дробления retired pages list), ибо это должно решить все проблемы.erigon доступен черновик фичи " bigfoot" для решения замедления транзакций в Ethereum с очень-большими транзакциями.#ifndef to MDBX_LOCK_SUFFIX to allow customization?
master branch, since devel contain experimantal features and will be rewritten.mdbx_load to load data into an mdbx DB created by Erigon with non-default pagesize (16kb), but it refuses to work, quitting with MDBX_INCOMPATIBLE; after enabling debugging + copying over the relevant console-logger into that utility, I get this more-specific error:
! could not apply preconfigured db-geometry: err 22
mdbx_env_set_geometry:
if ((uint64_t)size_lower / pagesize < MIN_PAGENO) {
rc = MDBX_EINVAL;
goto bailout;
}
size_lower is 12288pagesize is 16384
std::map<> с NVDIMM может быть рациональнее чем подключение libmdbx.madvise();msync(), fdatasync();/proc/sys/kernel/random/boot_id, есть ли CLOCK_BOOTTIME или CLOCK_MONOTONIC...
MDBX_EXCLUSIVE flag, but when the MDBX_DBG_LEGACY_MULTIOPEN is not set by mdbx_setup_debug().
libfpta tests, so the MDBX_DBG_LEGACY_MULTIOPEN was provided for ones.
std::map<>.
#ifdef CUSTOM_OSAL_H \n #include CUSTOM_OSAL_H \n #endif
- опциональное определение заглушек для ненужных/замещаемых/переопределяемых функций, например #define mdbx_mapresize(x, y, z) (ENOSYS)
Соответственно, со своей стороны я обеспечу интеграцию эти изменений, в том числе обрамление ненужных/замещаемых/переопределяемых функций гардами #ifndef mdbx_foobar / #endif.mdbx_cursor_put with differently sized data, I see very weird behavior.MDBX_CURRENT flag but it makes no difference.-i options is required for mdbx_chk.1 < 2, 2 < 3, but 3 < 1).
03;00;00;00;00;00;00;80 (8-byte sequence) and "attention" (string) with wrong order for builtin comparator.MDBX_WRITEMAP mode and put at exactly one data item per transaction.devel branch with -DMDBX_DEBUG=2 and don't alter debug flags by mdbx_setup_debug().put(). Sorry!
mdbx_cursor_get be in a dirty page? Do I always have to check it in write txns using mdbx_is_dirty or are there some cases where a check is obsolete?
abort() before the each of three return MDBX_PAGE_FULL .
git clone https://gitflic.ru/project/erthink/bsearch-try.gitcd bsearch-trymake$ git clone https://gitflic.ru/project/erthink/bsearch-try.git
$ cd bsearch-try
$ make bench
На Xeon 5317, gcc 11.3:| Function | Time | Diff | Ratio |Т.е. ускорение чуть больше чем в 4 раза, и пока я не нашел причин не верить этим цифрам ;)
|:-------------------------|----------:|---------:|------:|
| ly_bsearch_mini1() | 0.014409 | -75.23% | 4.04 |
| ly_bsearch_goto2() | 0.014736 | -74.67% | 3.95 |
| ly_bsearch_mini3() | 0.014840 | -74.49% | 3.92 |
| ly_bsearch_goto1() | 0.015054 | -74.12% | 3.86 |
| ly_bsearch_mini2() | 0.015115 | -74.01% | 3.85 |
| ly_bsearch_switch2() | 0.020880 | -64.10% | 2.79 |
| ly_bsearch_switch1() | 0.024750 | -57.45% | 2.35 |
| bsearch_libmdbx() | 0.057715 | -0.78% | 1.01 |
| bsearch_linux() | 0.058085 | -0.14% | 1.00 |
| std::lower_bound<> | 0.058167 | +0.00% | 1.00 |
| bsearch_stdlib() | 0.059757 | +2.73% | 0.97 |
make clean && CXX=clang++ make bench.-march=native на последних ядрах интел, где более-менее починили тормознутость cmov.B-extensions;B-extensions, то что он знает о latency и throughput...! в условии.__asm __volatile("" : "+r"(foo bar for dependency) : "r"(comparison result));bsearch() и std::lower_bound<> (собственно см исходники).-march=native| Function | Time | Diff | Ratio |clang-14 без
|:-----------------|----------:|---------:|------:|
| ly_bl_switch1 | 0.013019 | -72.12% | 3.59 |
| ly_bl_goto1 | 0.013075 | -72.00% | 3.57 |
| ly_bl_mini2 | 0.013100 | -71.95% | 3.56 |
| ly_bl_switch2 | 0.013126 | -71.89% | 3.56 |
| ly_bl_goto2 | 0.013165 | -71.81% | 3.55 |
| ly_bl_mini0 | 0.013223 | -71.68% | 3.53 |
| ly_bl_mini1 | 0.013248 | -71.63% | 3.52 |
| ly_bl_clz_switch | 0.013365 | -71.38% | 3.49 |
| ly_bl_mini3 | 0.013588 | -70.90% | 3.44 |
| ly_bl_clz_goto | 0.013668 | -70.73% | 3.42 |
| bsearch_libmdbx | 0.028976 | -37.94% | 1.61 |
| bsearch_linux | 0.030456 | -34.78% | 1.53 |
| std::lower_bound | 0.046694 | +0.00% | 1.00 |
| bsearch_stdlib | 0.047566 | +1.87% | 0.98 |
-march=native| Function | Time | Diff | Ratio |gcc-12 без
|:-----------------|----------:|---------:|------:|
| ly_bl_mini0 | 0.023544 | -23.57% | 1.31 |
| ly_bl_mini1 | 0.025137 | -18.40% | 1.23 |
| ly_bl_mini2 | 0.025902 | -15.91% | 1.19 |
| ly_bl_mini3 | 0.026880 | -12.74% | 1.15 |
| ly_bl_goto1 | 0.028402 | -7.80% | 1.08 |
| ly_bl_switch2 | 0.028410 | -7.77% | 1.08 |
| ly_bl_switch1 | 0.028461 | -7.61% | 1.08 |
| ly_bl_goto2 | 0.028463 | -7.60% | 1.08 |
| ly_bl_clz_goto | 0.028486 | -7.53% | 1.08 |
| ly_bl_clz_switch | 0.029184 | -5.26% | 1.06 |
| std::lower_bound | 0.030805 | +0.00% | 1.00 |
| bsearch_libmdbx | 0.034632 | +12.43% | 0.89 |
| bsearch_linux | 0.036243 | +17.66% | 0.85 |
| bsearch_stdlib | 0.048673 | +58.01% | 0.63 |
-march=native| Function | Time | Diff | Ratio |
|:-----------------|----------:|---------:|------:|
| ly_bl_goto1 | 0.012665 | -75.52% | 4.08 |
| ly_bl_mini1 | 0.012697 | -75.45% | 4.07 |
| ly_bl_mini2 | 0.012832 | -75.19% | 4.03 |
| ly_bl_goto2 | 0.012840 | -75.18% | 4.03 |
| ly_bl_mini0 | 0.012950 | -74.96% | 3.99 |
| ly_bl_mini3 | 0.013380 | -74.13% | 3.87 |
| ly_bl_clz_goto | 0.013479 | -73.94% | 3.84 |
| ly_bl_switch2 | 0.018024 | -65.16% | 2.87 |
| ly_bl_switch1 | 0.020905 | -59.59% | 2.47 |
| ly_bl_clz_switch | 0.021961 | -57.54% | 2.36 |
| bsearch_linux | 0.048620 | -6.01% | 1.06 |
| bsearch_libmdbx | 0.049127 | -5.03% | 1.05 |
| bsearch_stdlib | 0.050831 | -1.73% | 1.02 |
| std::lower_bound | 0.051727 | +0.00% | 1.00 |
-march=native clang генерирует чуть-ли не вдвое более медленный код, причем для функций где сложно что-либо испортить.-march=native и костылем __asm __volatile приближается к GCC, но при этом в полтора раза замедляет штатную реализацию std::lower_bound<>.
mdbx_cursor_get(MDBX_CURRENT) for non-positioned cursor, i.e. for a cursor which not positioned to the any entry.
MDBX_BUSY.
MDBX_DBG_LEGACY_MULTIOPEN) библиотека не должна позволить вам открыть одну БД (один и тот-же файл) дважды в одном процессе.MDBX_DBG_LEGACY_MULTIOPEN, то толжны полностью представлять последствия (розетка + пальцы = ...).MDBX_DB_LEGACY_MULTIOPEN я его явно не сетал, ща ещё раз проверю
MDBX_DB_LEGACY_MULTIOPEN можно только явно засетать через mdbx_setup_debug?
MDBX_CP_FORCE_DYNAMIC_SIZE. What does "resisable" mean in this context? If the copied database is not resizable can I not write to it?
mdbx_txn_abort() to avoid memory leak(s).
Undefined symbols for architecture arm64:
"___cxa_thread_atexit", referenced from:
_thread_rthc_set in libisar.a(mdbx.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)__cxa_thread_atexit since v0.11.8 (you can check this by git blame src/core.c and search for cxa_thread_atexit).MAC_OS_X_VERSION_MIN_REQUIRED.
-miphoneos-version-min=10.0
__cxa_thread_atexit() should be preferred when available, because it accepts a DSO-anchor to avoid unload DSO/DLL before all destructors are complete;MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 only the _tlv_atexit() is available on macOS.
MAC_OS_X_VERSION_MIN_REQUIRED you will get error "The <AvailabilityMacros.h> should be included and MAC_OS_X_VERSION_MIN_REQUIRED must be defined" during libmdbx build.
MAC_OS_X_VERSION_MIN_REQUIRED 🙂 what should I set it to?
devel branch for mdbx_env_openW().
scan4seq implementation for arm processors? Is that even possible?
scan4seq_sse2() as a template;scan4seq() required operation with 4-byte aligned numbers.vld1 instructions family that can read partially-aligned data.EINVAL to the MDBX_EINVAL.master branch.
MDBX_EINVAL . build pass with mingw X86 and X64.
MDBX_SYNC_DURABLE, because only synchronous write allows us to see the problem before overwriting the previous (not corrupted) snapshot of data.
MDBX_SYNC_DURABLE, if every transactions commit around 1024 pages, how many IOPS it will trigger ? msync(), fdatasync() or similar to flush written data to the HDD/SSD/NVMe.write() will be used/called regardless to "sync" or "no-sync".MDBX_SYNC_DURABLE. for default 4K page size, is there a best value size for it (like 4044 ) ? I always commit at batch ( like commit 1024 (or more pages) values at once). key size is fixed 8 byte. MDBX_NOMETASYNC - if you don't care about files after machine power-off then any syncmode is good for you. maybe you will need set some sync_period - i don't remember defaults.MDBX_NOMETASYNC | MDBX_EXCLUSIVE , disk io error will corrupt the in-memory-one-process database ?
/dev/shm (or similar) coud be used for disk-less cases.
MDBX_WRITEMAP updates using file descriptor going to the system/kernel's unified page cache and then the to a disk.fdatasync(), which can happen much later than the I/O error actually occurred.MDBX_WRITEMAP updates are performed only in RAM, and then written to disk asynchronously or forced at transaction committing.std::map<> or std::unordered_map<> under a mutex (for multithread cases) or some lockless solution.
MDBX_SYNC_DURABLE yesterday is use it for the RAFT snapshot state machine.MDBX_NOMETASYNC | MDBX_EXCLUSIVE , Is use to store the RAFT statue mache before the snapshot.MDBX_NOMETASYNC | MDBX_EXCLUSIVE to be persistent. But it must always be right, so the result read from it can safe distribute to other node.MDBX_SYNC_DURABLE commit into other store).MDBX_TXN_CHECKOWNER=0 build option;devel.EAGAIN be caused/avoided when trying to open an environment? 🧐
EAGAIN is returned by the kernel, and to find out the reason, you need to know which system call returned this error.strace or similar tool. MDBX_BUSY error should be returned.EAGAIN occurs outside the context of the locking mechanism used (depends on the platform), then the error is returned to the user as is.mmap()man setrlimit());EAGAIN occurs in the most unexpected places, if the system lacks some resources, or some kernel subsystem is overloaded.
14 files changed, 263 insertions(+), 252 deletions(-)
New:wchar_t in path names.__cxa_thread_atexit() on Apple's OSes.MultiByteToWideChar(CP_THREAD_ACP) instead of mbstowcs().MDBX_EINVAL which breaks MingGW builds with CLANG.ldd to check used dso.MDBX_WEAK_IMPORT_ATTRIBUTE macro.env_set_geometry() called within a write transaction.iov_page() failure case.EOVERFLOW hasn't used/returned in libmdbx, i.e. this error comes form the sysme/kernel.strace or similar tool.
note: Undefined symbols for architecture x86_64:
"___cpu_indicator_init", referenced from:
_scan4seq_resolver in libmdbx_sys-97b230ccc8c8d06a.rlib(mdbx.o)
"___cpu_model", referenced from:
_scan4seq_resolver in libmdbx_sys-97b230ccc8c8d06a.rlib(mdbx.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: relocation R_X86_64_PC32 cannot be used against symbol '__cpu_model'; recompile with -fPIC-fPIC or -fpic is used by default by CMake and inside GNUMakefile.-fpic has been missed for libgcc.
-fpic;EOVERFLOW https://github.com/isar/isar/issues/589
mt_dbxs - это внутреннее поле транзакции указывающее на массив вспомогательных структур для открытых DBI-хендлов, т.е. пока вы не откроете subDB там ничего не появиться.MDBX_DB_ACCEDE.mdbx_drop с третьим аргументом truedevel branch.master branch after the 0.12.1 release.
master branch, it works for me.
MDBX_HAVE_BUILTIN_CPU_SUPPORTS=0 build option as a workaround.
MDBX_HAVE_BUILTIN_CPU_SUPPORTS=0 works, will it have any side effect?
MDBX_HAVE_BUILTIN_CPU_SUPPORTS=0 is just forced by default.
MDBX_HAVE_BUILTIN_CPU_SUPPORTS=0
libmdbx:v0.12.1, but succeed with masterv0.12.1 and masterv0.12.1-DNDEBUG.
FlushViewOfFile() и FlushFileBuffers() (в процессе починки, но есть затруднения с самой ОС).gcrtime_seconds16dot16 из MDBX_envinfo и gc из MDBX_commit_latency.mdbx_setup_debug()) и посмотреть что происходит при коммите.
git grep oldest_reader
FlushViewOfFile() и FlushFileBuffers()).MDBX_SAFE_NOSYNC приводит к принудительному сбросу данных на диск при подготовке задела страниц и слотов перед обновлением GC.qemu-riscv64 version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.4) не заработало, если не ошибаюсь то проблема в отсутствии поддержки OFD-блокировок для fcntl().off_t type is wider than corresponding fields of struct flock used for file locking. Now libmdbx will use fcntl64(F_GETLK64/F_SETLK64/F_SETLKW64) if available.page_retire_ex().-Wint-to-pointer-cast warnings while casting to mdbx_tid_t.LockFileEx() inside mdbx_env_copy().2022-10-13T13:20:15.570403Z INFO { 12/12 Finish }: DONE @ 15739453 in 00:00:00.000
2022-10-13T13:20:15.570425Z INFO Staged sync complete. Headers=00:00:04.700 TotalGasIndex=00:00:00.000 BlockHashes=00:00:00.000 Bodies=00:00:04.193 TotalTxIndex=00:00:00.008 SenderRecovery=00:00:00.020 Execution=00:00:02.269 AccountHistoryIndex=00:00:00.935 StorageHistoryIndex=00:00:01.474 TxLookup=00:00:01.058 CallTraces=00:00:02.688 Finish=00:00:00.000
akula: mdbx:9268: map_resize: Assertion `size_bytes == env->me_dxb_mmap.current' failed.
[1] 1111536 IOT instruction (core dumped)CMake Error at 3rd/libmdbx/cmake/utils.cmake:148 (message):
Please fetch tags (no any tags for 141 commits)
Call Stack (most recent call first):
3rd/libmdbx/CMakeLists.txt:553 (fetch_version)
-- Configuring incomplete, errors occurred!
git fetch --tags из папки с либой запустить?
mdbx_env_warmup().master сейчас готова для релиза.stable-ветки: workaround для encryptfs, исправления сборки для устаревших систем и экзотических конфигураций buildroot.
page_alloc_slowpath().
mdbx_env_set_syncbytes() это shortcut для mdbx_env_set_option(MDBX_opt_sync_bytes);mdbx_env_set_option(env, MDBX_opt_sync_bytes) вызывает mdbx_env_sync_poll() если БД уже открыта;mdbx_env_sync_poll() это shortcut для mdbx_env_sync_ex(env, force=false, nonblock=true);mdbx_env_sync_ex(env, force=false, nonblock=true) смотрит на состояние БД и заданные sync_bytes c sync_period, а если требуется сброс данных на диск, то пытается его выполнить.mdbx_env_sync_ex(env, force=false, nonblock=true),MDBX_BUSY.LockFileEx(..., LOCKFILE_FAIL_IMMEDIATELY, ...) могут возвращать ложно-положительный конфликт, ибо nonblock=false при вызове mdbx_env_sync_ex() изнутри mdbx_env_set_option().
C just see the implementations of these methods inside the mdbx.c++
mdbx_dbi_stat(txn, dbi, &stat) and then checks stat.ms_entries.
mv_size but the iov_len of struct iovec.EmptyBytesArray (including LMDB), but libmdbx can.Nil from EmptyBytesArray, an additional flag-prefix is placed at the beginning of the value and/or key, etc.Nil from EmptyBytesArray in an instances of struct iovec the iov_base is useful, i.e. {nullptr, 0} means Nil and {"" /* any non-null pointer */, 0} means EmptyBytesArray.
{address_inside_a_DB_page, 0} for zero-length keys and/or values (i.e. non-nullptr iov_base).NIL.
env->me_dxb_mmap).devel следующим коммитом проблема устранена полностью.
mdbx:9268: map_resize: Assertion `size_bytes == env->me_dxb_mmap.current' failed. и уже пошли рассуждения о плохом коде и низкой надежности libmdbx, хотя в текущем понимании баг в glibc или в докере.assert().v0.12.2 в статусе pre-release.devel и волью в master.v0.12.1.
DllMain().__declspec(allocate(".CRT$XLB")) or __attribute__((__section__(".CRT$XLB"), used)).v0.11.13 (stable bugfix) scheduled at 2022-11-10, the stable branch at https://gitflic.ru/project/erthink/libmdbxv0.12.2 (frontward) scheduled at 2022-11-11, the master branch at https://gitflic.ru/project/erthink/libmdbxLINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
mdbx.lib(mdbx.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReport
CMakeLists.txt is provided which is smart enough to solve such problems.30 files changed, 405 insertions(+), 136 deletions(-)https://gitflic.ru/project/erthink/libmdbx/release/82bf302a-81fe-4b9c-8309-4bd39e9233d6
MDBX_INTEGERKEY, MDBX_INTEGERDUP (I'm not 100% sure, but probably it saving 8-bytes per key, because don't need store key length)MDBX_opt_merge_threshold_16dot16_percentMDBX_MULTIPLE (to reduce amount of keys/values - it saving 8-bytes per key, because don't need store key length). To navigate in shards can use next trick: switch table format from "key_id -> value" to "shard_id -> list_of_values" - where "shard_id = max_key_id_inside_given_shard | MaxUint64_for_the_last_shard". Then request like MDBX_SET_RANGE(key_id) will return correct "shard_id -> list_of_values" pair - and you will manually search your value inside list_of_values. version -> [ node, ...], and the nodes can be accessed by (version, index). and we may or may not need to prune the tree, if not prune the tree, we don't need to delete anything ever, I think I can optimize for both cases separately.list_of_values you mentioned, we also need to prepend a list of offsets (the whole version is written out in a batch, so that's possible), right?
version(dupsort) -> [(index(int key), node)]
version -> (offsets, list of compressed nodes), I guess this should be most space efficient format
mdbx_env_create() will return MDBX_INCOMPATIBLE.SIGSEGV is unexpected unless you ignore a returning code(s) and/or dereference invalid/uninitialized pointer(s).
linux_kernel_version < xxx
i.e. git grep linux_kernel_version | grep -i assert
However, it would be a deception to say that everything will work on old kernels.test/long_stochastic.sh inside libmdbx repo) on the target system with old kernel.free() don't accepts NULL.if (ior->pool) before osal_free(ior->pool).-1 with 0 in the next line memset(ior, -1, sizeof(osal_ioring_t)) after the osal_free() call.
mdbx_env_close() simultaneously from multiple threads, i.e. not from a single.
memset(ior, 0, sizeof(osal_ioring_t)); may help if only the osal_ioring_destroy() is called twice.osal_ioring_destroy() is called only from the env_close() and if the MDBX_ENV_ACTIVE bit is set.MDBX_ENV_ACTIVE is cleared (by the env->me_flags &= ~ENV_INTERNAL_FLAGS) before calling the osal_ioring_destroy().osal_ioring_destroy() will be called once, and only after the mdbx_env_open().env_close() code and don't really understand how this error can even happen since all the frees are checked 0x20524 abort + 168
3 libsystem_malloc.dylib 0x1ca04 _malloc_put + 550
4 libsystem_malloc.dylib 0x1cbdc malloc_report + 64
5 libsystem_malloc.dylib 0x1e38 free + 300
6 isar_flutter_libs 0xca588 env_close + 136
7 isar_flutter_libs 0xc8284 mdbx_env_open + 1644
8 isar_flutter_libs 0x4d470 isar_core::instance::IsarInstance::open_internal::h5dfcafd44edbc112 + 736
a1333fc827bba3fb0a2c5d9c718177d27cc2cf5f.devel branch.
mdbx_chk несколько раз задав опцию -v, т.е. например mdbx_chk -vvvvv path-todb
0.12.x and most likely 0.13.x will support Windows.M386AAG40MMB-CVF×12 or M386AAG40MMB-CWE×16 to complete the upgrade of my equipment and provide it with uniform memory.
MDBX_WRITEMAP выделение/переиспользование страниц приводит к page-fault и чтению страницы с диска, даже если содержимое страницы не нужно (будет перезаписано).MADV_REMOVE работает не на всех ФС и обычно дороже получаемой экономии.MDBX_opt_writethrough_threshold.O_DSYNC;fdatasync().MDBX_opt_writethrough_threshold позволяет во время выполнения задать порог для динамического выбора способа записи.MDBX_AVOID_MSYNC=0 при сборке = будет использоваться FlushViewOfFile() и FlushFileBuffers().MDBX_SYNC_DURABLE at the end of commit() all data are on a disk, but the option is a way to do this: write() to file descriptor opened with O_DSYNC either write() + fdatasync().
MDBX_TXN_NOSYNC for some transactions):MDBX_TXN_NOSYNC)MDBX_TXN_NOSYNC ( we must do this transaction anyway )
mdbx_txn_begin() with MDBX_TXN_NOSYNC either MDBX_TXN_NOMETASYNC to do such.
master branch.$ make -C libmdbx bench-couple
make: вход в каталог «/home/xyz/libmdbx»
// The GNU Make 4.3
// TIP: Use `make V=1` for verbose.
MDBX_BUILD_OPTIONS = -DNDEBUG=1
MDBX_BUILD_CXX = YES
MDBX_BUILD_TIMESTAMP = 2022-12-14T11:07:33+0300
// TIP: Use `make options` to listing available build options.
CXX =/usr/bin/g++ | g++ (Ubuntu 11.3.0-1ubuntu1) 11.3.0
CXXFLAGS =-std=gnu++23 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes -fno-semantic-interposition -Wno-unused-command-line-argument -Wno-tautological-compare
LDFLAGS =-Wl,--gc-sections,-z,relro,-O1 -Wl,--allow-multiple-definition -lstdc++fs -lm -lrt -pthread
// TIP: Use `make help` to listing available targets.
CLEAN for build with specified flags... Ok
MAKE src/version.c
MAKE src/config.h
CC mdbx-static.o
CC mdbx++-static.o
AR libmdbx.a
CC mdbx-dylib.o
CC mdbx++-dylib.o
LD libmdbx.so
CC+LD mdbx_stat
CC+LD mdbx_copy
CC+LD mdbx_dump
CC+LD mdbx_load
CC+LD mdbx_chk
CC+LD mdbx_drop
RUNNING ioarena for mdbx/25000000...
linux-vdso.so.1 (0x00007ffe2b3c1000)
liblmdb.so => /home/xyz/ioarena/@BUILD/db/lmdb/libraries/liblmdb/liblmdb.so (0x00007fb4860d0000)
libmdbx.so => ./libmdbx.so (0x00007fb486064000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb485f67000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb485d3f000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb485b13000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb485af3000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb4860ff000)
throughput: 199.566Kops/s
throughput: 46.082Mops/s
throughput: 3.075Mops/s
RUNNING ioarena for lmdb/25000000...
linux-vdso.so.1 (0x00007ffefadeb000)
liblmdb.so => /home/xyz/ioarena/@BUILD/db/lmdb/libraries/liblmdb/liblmdb.so (0x00007f99e1d0c000)
libmdbx.so => ./libmdbx.so (0x00007f99e1ca0000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f99e1ba3000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f99e197b000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f99e174f000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f99e172f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f99e1d3b000)
throughput: 171.387Kops/s
throughput: 42.069Mops/s
throughput: 2.339Mops/s
mdbx_dbi_open() ?
1.tls_model for the rthc_thread_state (which is a local-thread storage variable, i.e. defined with __thread).local-exec and initial-exec models are unavailable for __thread variable in a DSO with -shared.-fPIC and/or -shared cases.-ftls-model option, i.e. try -ftls-model global-dynamic.__attribute__((tls_model("local-dynamic"))), i.e.:diff --git a/src/core.c b/src/core.c
index 40336995..84c6dcad 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1164,7 +1164,7 @@ static __inline uint64_t rthc_signature(const void *addr, uint8_t kind) {
#define MDBX_THREAD_RTHC_REGISTERED(addr) rthc_signature(addr, 0x0D)
#define MDBX_THREAD_RTHC_COUNTED(addr) rthc_signature(addr, 0xC0)
-static __thread uint64_t rthc_thread_state;
+static __thread uint64_t rthc_thread_state __attribute__((tls_model("local-dynamic")));
#if defined(__APPLE__) && defined(__SANITIZE_ADDRESS__) && \
!defined(MDBX_ATTRIBUTE_NO_SANITIZE_ADDRESS)
mdbx_reader_check().
write() system call.MDBX_SYNC_DURABLE modes.LockFileEx() during staring write transaction, but not for read-only.let env = Environment::new()
.set_flags(Mode::ReadOnly.into())
.set_max_dbs(32)
.open(Path::new(dir))
.unwrap();