Skip to content

Commit 158556d

Browse files
JkLondonJkLondon
andauthored
new version of mdbx (#184)
* new version of mdbx * Add test for cursor binding on empty DBI and improve test coverage. * Remove debug println and skip TestCursor_BindOnEmptyDbi temporarily --------- Co-authored-by: JkLondon <ilya@mikheev.fun>
1 parent 6c3d446 commit 158556d

File tree

17 files changed

+1282
-749
lines changed

17 files changed

+1282
-749
lines changed

mdbx/cursor_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,15 @@ func TestCursor_Bind(t *testing.T) {
14061406
return
14071407
}
14081408

1409+
err = env.Update(func(txn *Txn) (err error) {
1410+
db2, err = txn.CreateDBI("testing2")
1411+
return err
1412+
})
1413+
if err != nil {
1414+
t.Error(err)
1415+
return
1416+
}
1417+
14091418
err = env.Update(func(txn *Txn) (err error) {
14101419
put := func(k, v string) {
14111420
if err == nil {
@@ -1477,6 +1486,44 @@ func TestCursor_Bind(t *testing.T) {
14771486
}
14781487
}
14791488

1489+
func TestCursor_BindOnEmptyDbi(t *testing.T) {
1490+
t.Skip() // TODO: uncomment on v0.13.6
1491+
env, _ := setup(t)
1492+
1493+
var db1, db2 DBI
1494+
err := env.Update(func(txn *Txn) (err error) {
1495+
db1, err = txn.CreateDBI("testing1")
1496+
return err
1497+
})
1498+
if err != nil {
1499+
t.Error(err)
1500+
return
1501+
}
1502+
1503+
var cur *Cursor
1504+
err = env.View(func(txn *Txn) (err error) {
1505+
cur, err = txn.OpenCursor(db2)
1506+
if err != nil {
1507+
return err
1508+
}
1509+
return nil
1510+
})
1511+
if err != nil {
1512+
t.Error(err)
1513+
}
1514+
1515+
err = env.View(func(txn *Txn) (err error) {
1516+
err = cur.Bind(txn, db1)
1517+
if err != nil {
1518+
return err
1519+
}
1520+
return nil
1521+
})
1522+
if err != nil {
1523+
t.Error(err)
1524+
}
1525+
}
1526+
14801527
func BenchmarkCursor(b *testing.B) {
14811528
env, _ := setup(b)
14821529

mdbxdist/ChangeLog.md

Lines changed: 132 additions & 2 deletions
Large diffs are not rendered by default.

mdbxdist/GNUmakefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ else
164164
$(info $(TIP) Use `make V=1` for verbose.)
165165
endif
166166

167+
ifeq ($(UNAME),Darwin)
168+
$(info $(TIP) Use `brew install gnu-sed gnu-tar` and add ones to the beginning of the PATH.)
169+
endif
170+
167171
all: show-options $(LIBRARIES) $(MDBX_TOOLS)
168172

169173
help:
@@ -262,6 +266,10 @@ lib-shared libmdbx.$(SO_SUFFIX): mdbx-dylib.o $(call select_by,MDBX_BUILD_CXX,md
262266
@echo ' LD $@'
263267
$(QUIET)$(call select_by,MDBX_BUILD_CXX,$(CXX) $(CXXFLAGS),$(CC) $(CFLAGS)) $^ -pthread -shared $(LDFLAGS) $(call select_by,MDBX_BUILD_CXX,$(LIB_STDCXXFS)) $(LIBS) -o $@
264268

269+
ninja-assertions: CMAKE_OPT += -DMDBX_FORCE_ASSERTIONS=ON
270+
ninja-assertions: cmake-build
271+
ninja-debug: CMAKE_OPT += -DCMAKE_BUILD_TYPE=Debug
272+
ninja-debug: cmake-build
265273
ninja: cmake-build
266274
cmake-build:
267275
@echo " RUN: cmake -G Ninja && cmake --build"
@@ -375,13 +383,13 @@ bench-$(1)_$(2).txt: $(3) $(IOARENA) $(lastword $(MAKEFILE_LIST))
375383
$(QUIET)(export LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}"; \
376384
ldd $(IOARENA) | grep -i $(1) && \
377385
$(IOARENA) -D $(1) -B batch -m $(BENCH_CRUD_MODE) -n $(2) \
378-
| tee $$@ | grep throughput | sed 's/throughput/batch×N/' && \
386+
| tee $$@ | grep throughput | $(SED) 's/throughput/batch×N/' && \
379387
$(IOARENA) -D $(1) -B crud -m $(BENCH_CRUD_MODE) -n $(2) \
380-
| tee -a $$@ | grep throughput | sed 's/throughput/ crud/' && \
388+
| tee -a $$@ | grep throughput | $(SED) 's/throughput/ crud/' && \
381389
$(IOARENA) -D $(1) -B iterate,get,iterate,get,iterate -m $(BENCH_CRUD_MODE) -r 4 -n $(2) \
382-
| tee -a $$@ | grep throughput | sed '0,/throughput/{s/throughput/iterate/};s/throughput/ get/' && \
390+
| tee -a $$@ | grep throughput | $(SED) '0,/throughput/{s/throughput/iterate/};s/throughput/ get/' && \
383391
$(IOARENA) -D $(1) -B delete -m $(BENCH_CRUD_MODE) -n $(2) \
384-
| tee -a $$@ | grep throughput | sed 's/throughput/ delete/' && \
392+
| tee -a $$@ | grep throughput | $(SED) 's/throughput/ delete/' && \
385393
true) || mv -f $$@ $$@.error
386394

387395
endef

mdbxdist/README.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,51 @@ Historically, _libmdbx_ is a deeply revised and extended descendant of the amazi
6464
[Lightning Memory-Mapped Database](https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database).
6565
_libmdbx_ inherits all benefits from _LMDB_, but resolves some issues and adds [a set of improvements](#improvements-beyond-lmdb).
6666

67-
### MithrilDB and Future
67+
## Github
68+
69+
### на Русском (мой родной язык)
70+
71+
Весной 2022, без каких-либо предупреждений или пояснений, администрация
72+
Github удалила мой аккаунт и все проекты. Через несколько месяцев, без
73+
какого-либо моего участия или уведомления, проекты были
74+
восстановлены/открыты в статусе "public read-only archive" из какой-то
75+
неполноценной резервной копии. Эти действия Github я расцениваю как
76+
злонамеренный саботаж, а сам сервис Github считаю навсегда утратившим
77+
какое-либо доверие.
78+
79+
Вследствие произошедшего, никогда и ни при каких условиях, я не буду
80+
размещать на Github первоисточники (aka origins) моих проектов, либо
81+
как-либо полагаться на инфраструктуру Github.
82+
83+
Тем не менее, понимая что пользователям моих проектов удобнее получать к
84+
ним доступ именно на Github, я не хочу ограничивать их свободу или
85+
создавать неудобство, и поэтому размещаю на Github зеркала (aka mirrors)
86+
репозиториев моих проектов. При этом ещё раз акцентирую внимание, что
87+
это только зеркала, которые могут быть заморожены, заблокированы или
88+
удалены в любой момент, как это уже было в 2022.
89+
90+
### in English
91+
92+
In the spring of 2022, without any warnings or explanations, the Github
93+
administration deleted my account and all projects. A few months later,
94+
without any involvement or notification from me, the projects were
95+
restored/opened in the "public read-only archive" status from some kind
96+
of incomplete backup. I regard these actions of Github as malicious
97+
sabotage, and I consider the Github service itself to have lost any
98+
trust forever.
99+
100+
As a result of what has happened, I will never, under any circumstances,
101+
post the primary sources (aka origins) of my projects on Github, or rely
102+
in any way on the Github infrastructure.
103+
104+
Nevertheless, realizing that it is more convenient for users of my
105+
projects to access them on Github, I do not want to restrict their
106+
freedom or create inconvenience, and therefore I place mirrors of my
107+
project repositories on Github. At the same time, I would like to
108+
emphasize once again that these are only mirrors that can be frozen,
109+
blocked or deleted at any time, as was the case in 2022.
110+
111+
## MithrilDB and Future
68112

69113
<!-- section-begin mithril -->
70114

@@ -234,7 +278,7 @@ which is also (mostly) applicable to _libmdbx_ with minor clarification:
234278
- a database could shared by multiple processes, i.e. no multi-process issues;
235279
- no issues with moving a cursor(s) after the deletion;
236280
- _libmdbx_ provides zero-overhead database compactification, so a database file could be shrinked/truncated in particular cases;
237-
- excluding dist I/O time _libmdbx_ could be -3 times faster than BoltDB and up to 10-100K times faster than both BoltDB and LMDB in particular extreme cases;
281+
- excluding disk I/O time _libmdbx_ could be 3 times faster than BoltDB and up to 10-100K times faster than both BoltDB and LMDB in particular extreme cases;
238282
- _libmdbx_ provides more features compared to BoltDB and/or LMDB.
239283

240284
<!-- section-end -->
@@ -602,16 +646,19 @@ error when opening the database in a _WSL1_ environment.
602646
### MacOS
603647
Current [native build tools](https://en.wikipedia.org/wiki/Xcode) for
604648
MacOS include GNU Make, CLANG and an outdated version of Bash.
605-
Therefore, to build the library, it is enough to run `make all` in the
649+
However, the build script uses GNU-kind of `sed` and `tar`.
650+
So the easiest way to install all prerequirements is to use [Homebrew](https://brew.sh/),
651+
just by `brew install bash make cmake ninja gnu-sed gnu-tar --with-default-names`.
652+
653+
Next, to build the library, it is enough to run `make all` in the
606654
directory with source code, and run `make check` to execute the base
607655
tests. If something goes wrong, it is recommended to install
608656
[Homebrew](https://brew.sh/) and try again.
609657

610658
To run the [long stochastic test scenario](test/stochastic.sh), you
611659
will need to install the current (not outdated) version of
612-
[Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)). To do this, I
613-
recommend that you install [Homebrew](https://brew.sh/) and then execute
614-
`brew install bash`.
660+
[Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)).
661+
Just install it as noted above.
615662

616663
### Android
617664
I recommend using CMake to build _libmdbx_ for Android.
@@ -641,6 +688,7 @@ Bindings
641688
| Java | [mdbxjni](https://github.com/castortech/mdbxjni) | [Castor Technologies](https://castortech.com/) |
642689
| Go | [mdbx-go](https://github.com/torquem-ch/mdbx-go) | [Alex Sharov](https://github.com/AskAlexSharov) |
643690
| Ruby | [ruby-mdbx](https://rubygems.org/gems/mdbx/) | [Mahlon E. Smith](https://github.com/mahlonsmith) |
691+
| Zig | [mdbx-zig](https://github.com/theseyan/lmdbx-zig) | [Sayan J. Das](https://github.com/theseyan) |
644692

645693
##### Obsolete/Outdated/Unsupported:
646694

mdbxdist/VERSION.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "git_describe": "v0.13.4-0-g75122b31", "git_timestamp": "2025-02-14T12:56:12+03:00", "git_tree": "9b87c2c14d40bb9e9963b46c3d8d328a3f4ebe7d", "git_commit": "75122b311d3672409823d2477564689ec0be082c", "semver": "0.13.4" }
1+
{ "git_describe": "v0.13.5-0-ge3324cef", "git_timestamp": "2025-03-21T21:14:00+03:00", "git_tree": "eaa12f8b818d12a92de2b9a3bde3b5ea223953a0", "git_commit": "e3324cef918407fe48c90e513577ec99a0d15b62", "semver": "0.13.5" }

mdbxdist/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.13.1.56
1+
0.12.13.0

mdbxdist/cmake/compiler.cmake

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,11 @@ if(CMAKE_COMPILER_IS_GNU${CMAKE_PRIMARY_LANG}
502502
AND CMAKE_GCC_RANLIB
503503
AND gcc_lto_wrapper)
504504
message(STATUS "Found GCC's LTO toolset: ${gcc_lto_wrapper}, ${CMAKE_GCC_AR}, ${CMAKE_GCC_RANLIB}")
505-
set(GCC_LTO_CFLAGS "-flto -fno-fat-lto-objects -fuse-linker-plugin")
505+
if(CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 11.4)
506+
set(GCC_LTO_CFLAGS "-flto -fno-fat-lto-objects -fuse-linker-plugin")
507+
else()
508+
set(GCC_LTO_CFLAGS "-flto=auto -fno-fat-lto-objects -fuse-linker-plugin")
509+
endif()
506510
set(GCC_LTO_AVAILABLE TRUE)
507511
message(STATUS "Link-Time Optimization by GCC is available")
508512
else()
@@ -541,13 +545,21 @@ if(CMAKE_COMPILER_IS_CLANG)
541545
if(regexp_valid)
542546
string(REGEX REPLACE "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs})
543547
string(REPLACE ":" ";" list "${list}")
548+
set(libs_extra_subdirs "lib;../lib;lib64;../lib64;lib32;../lib32")
544549
foreach(dir IN LISTS list)
545550
get_filename_component(dir "${dir}" REALPATH)
546551
if(dir MATCHES ".*llvm.*" OR dir MATCHES ".*clang.*")
547-
list(APPEND clang_bindirs "${dir}")
552+
set(list_suffix "")
548553
else()
549-
list(APPEND clang_bindirs_x "${dir}")
554+
set(list_suffix "_x")
550555
endif()
556+
list(APPEND clang_bindirs${list_suffix} "${dir}")
557+
foreach(subdir IN LISTS libs_extra_subdirs)
558+
get_filename_component(subdir "${dir}/${subdir}" REALPATH)
559+
if(EXISTS "${subdir}")
560+
list(APPEND clang_libdirs${list_suffix} "${subdir}")
561+
endif()
562+
endforeach()
551563
endforeach()
552564
list(APPEND clang_bindirs "${clang_bindirs_x}")
553565
list(REMOVE_DUPLICATES clang_bindirs)
@@ -559,10 +571,11 @@ if(CMAKE_COMPILER_IS_CLANG)
559571
foreach(dir IN LISTS list)
560572
get_filename_component(dir "${dir}" REALPATH)
561573
if(dir MATCHES ".*llvm.*" OR dir MATCHES ".*clang.*")
562-
list(APPEND clang_libdirs "${dir}")
574+
set(list_suffix "")
563575
else()
564-
list(APPEND clang_libdirs_x "${dir}")
576+
set(list_suffix "_x")
565577
endif()
578+
list(APPEND clang_libdirs${list_suffix} "${dir}")
566579
endforeach()
567580
list(APPEND clang_libdirs "${clang_libdirs_x}")
568581
list(REMOVE_DUPLICATES clang_libdirs)
@@ -656,7 +669,7 @@ if(CMAKE_COMPILER_IS_CLANG)
656669
AND CMAKE_CLANG_NM
657670
AND CMAKE_CLANG_RANLIB
658671
AND ((CLANG_LTO_PLUGIN AND CMAKE_LD_GOLD)
659-
OR (CMAKE_CLANG_LD AND NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
672+
OR CMAKE_CLANG_LD
660673
OR APPLE))
661674
if(ANDROID AND CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 12)
662675
set(CLANG_LTO_AVAILABLE FALSE)

0 commit comments

Comments
 (0)