Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions mdbx/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,15 @@ func TestCursor_Bind(t *testing.T) {
return
}

err = env.Update(func(txn *Txn) (err error) {
db2, err = txn.CreateDBI("testing2")
return err
})
if err != nil {
t.Error(err)
return
}

err = env.Update(func(txn *Txn) (err error) {
put := func(k, v string) {
if err == nil {
Expand Down Expand Up @@ -1477,6 +1486,44 @@ func TestCursor_Bind(t *testing.T) {
}
}

func TestCursor_BindOnEmptyDbi(t *testing.T) {
t.Skip() // TODO: uncomment on v0.13.6
env, _ := setup(t)

var db1, db2 DBI
err := env.Update(func(txn *Txn) (err error) {
db1, err = txn.CreateDBI("testing1")
return err
})
if err != nil {
t.Error(err)
return
}

var cur *Cursor
err = env.View(func(txn *Txn) (err error) {
cur, err = txn.OpenCursor(db2)
if err != nil {
return err
}
return nil
})
if err != nil {
t.Error(err)
}

err = env.View(func(txn *Txn) (err error) {
err = cur.Bind(txn, db1)
if err != nil {
return err
}
return nil
})
if err != nil {
t.Error(err)
}
}

func BenchmarkCursor(b *testing.B) {
env, _ := setup(b)

Expand Down
134 changes: 132 additions & 2 deletions mdbxdist/ChangeLog.md

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions mdbxdist/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ else
$(info $(TIP) Use `make V=1` for verbose.)
endif

ifeq ($(UNAME),Darwin)
$(info $(TIP) Use `brew install gnu-sed gnu-tar` and add ones to the beginning of the PATH.)
endif

all: show-options $(LIBRARIES) $(MDBX_TOOLS)

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

ninja-assertions: CMAKE_OPT += -DMDBX_FORCE_ASSERTIONS=ON
ninja-assertions: cmake-build
ninja-debug: CMAKE_OPT += -DCMAKE_BUILD_TYPE=Debug
ninja-debug: cmake-build
ninja: cmake-build
cmake-build:
@echo " RUN: cmake -G Ninja && cmake --build"
Expand Down Expand Up @@ -375,13 +383,13 @@ bench-$(1)_$(2).txt: $(3) $(IOARENA) $(lastword $(MAKEFILE_LIST))
$(QUIET)(export LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}"; \
ldd $(IOARENA) | grep -i $(1) && \
$(IOARENA) -D $(1) -B batch -m $(BENCH_CRUD_MODE) -n $(2) \
| tee $$@ | grep throughput | sed 's/throughput/batch×N/' && \
| tee $$@ | grep throughput | $(SED) 's/throughput/batch×N/' && \
$(IOARENA) -D $(1) -B crud -m $(BENCH_CRUD_MODE) -n $(2) \
| tee -a $$@ | grep throughput | sed 's/throughput/ crud/' && \
| tee -a $$@ | grep throughput | $(SED) 's/throughput/ crud/' && \
$(IOARENA) -D $(1) -B iterate,get,iterate,get,iterate -m $(BENCH_CRUD_MODE) -r 4 -n $(2) \
| tee -a $$@ | grep throughput | sed '0,/throughput/{s/throughput/iterate/};s/throughput/ get/' && \
| tee -a $$@ | grep throughput | $(SED) '0,/throughput/{s/throughput/iterate/};s/throughput/ get/' && \
$(IOARENA) -D $(1) -B delete -m $(BENCH_CRUD_MODE) -n $(2) \
| tee -a $$@ | grep throughput | sed 's/throughput/ delete/' && \
| tee -a $$@ | grep throughput | $(SED) 's/throughput/ delete/' && \
true) || mv -f $$@ $$@.error

endef
Expand Down
60 changes: 54 additions & 6 deletions mdbxdist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,51 @@ Historically, _libmdbx_ is a deeply revised and extended descendant of the amazi
[Lightning Memory-Mapped Database](https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database).
_libmdbx_ inherits all benefits from _LMDB_, but resolves some issues and adds [a set of improvements](#improvements-beyond-lmdb).

### MithrilDB and Future
## Github

### на Русском (мой родной язык)

Весной 2022, без каких-либо предупреждений или пояснений, администрация
Github удалила мой аккаунт и все проекты. Через несколько месяцев, без
какого-либо моего участия или уведомления, проекты были
восстановлены/открыты в статусе "public read-only archive" из какой-то
неполноценной резервной копии. Эти действия Github я расцениваю как
злонамеренный саботаж, а сам сервис Github считаю навсегда утратившим
какое-либо доверие.

Вследствие произошедшего, никогда и ни при каких условиях, я не буду
размещать на Github первоисточники (aka origins) моих проектов, либо
как-либо полагаться на инфраструктуру Github.

Тем не менее, понимая что пользователям моих проектов удобнее получать к
ним доступ именно на Github, я не хочу ограничивать их свободу или
создавать неудобство, и поэтому размещаю на Github зеркала (aka mirrors)
репозиториев моих проектов. При этом ещё раз акцентирую внимание, что
это только зеркала, которые могут быть заморожены, заблокированы или
удалены в любой момент, как это уже было в 2022.

### in English

In the spring of 2022, without any warnings or explanations, the Github
administration deleted my account and all projects. A few months later,
without any involvement or notification from me, the projects were
restored/opened in the "public read-only archive" status from some kind
of incomplete backup. I regard these actions of Github as malicious
sabotage, and I consider the Github service itself to have lost any
trust forever.

As a result of what has happened, I will never, under any circumstances,
post the primary sources (aka origins) of my projects on Github, or rely
in any way on the Github infrastructure.

Nevertheless, realizing that it is more convenient for users of my
projects to access them on Github, I do not want to restrict their
freedom or create inconvenience, and therefore I place mirrors of my
project repositories on Github. At the same time, I would like to
emphasize once again that these are only mirrors that can be frozen,
blocked or deleted at any time, as was the case in 2022.

## MithrilDB and Future

<!-- section-begin mithril -->

Expand Down Expand Up @@ -234,7 +278,7 @@ which is also (mostly) applicable to _libmdbx_ with minor clarification:
- a database could shared by multiple processes, i.e. no multi-process issues;
- no issues with moving a cursor(s) after the deletion;
- _libmdbx_ provides zero-overhead database compactification, so a database file could be shrinked/truncated in particular cases;
- 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;
- 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;
- _libmdbx_ provides more features compared to BoltDB and/or LMDB.

<!-- section-end -->
Expand Down Expand Up @@ -602,16 +646,19 @@ error when opening the database in a _WSL1_ environment.
### MacOS
Current [native build tools](https://en.wikipedia.org/wiki/Xcode) for
MacOS include GNU Make, CLANG and an outdated version of Bash.
Therefore, to build the library, it is enough to run `make all` in the
However, the build script uses GNU-kind of `sed` and `tar`.
So the easiest way to install all prerequirements is to use [Homebrew](https://brew.sh/),
just by `brew install bash make cmake ninja gnu-sed gnu-tar --with-default-names`.

Next, to build the library, it is enough to run `make all` in the
directory with source code, and run `make check` to execute the base
tests. If something goes wrong, it is recommended to install
[Homebrew](https://brew.sh/) and try again.

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

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

##### Obsolete/Outdated/Unsupported:

Expand Down
2 changes: 1 addition & 1 deletion mdbxdist/VERSION.json
Original file line number Diff line number Diff line change
@@ -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" }
{ "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" }
2 changes: 1 addition & 1 deletion mdbxdist/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.1.56
0.12.13.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the version going backward?
Should this read 0.13.5?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an obsolete file from the old version, the new version provides VERSION.json. The update to the new version was not done quite correctly, I will try to fix it soon.

25 changes: 19 additions & 6 deletions mdbxdist/cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,11 @@ if(CMAKE_COMPILER_IS_GNU${CMAKE_PRIMARY_LANG}
AND CMAKE_GCC_RANLIB
AND gcc_lto_wrapper)
message(STATUS "Found GCC's LTO toolset: ${gcc_lto_wrapper}, ${CMAKE_GCC_AR}, ${CMAKE_GCC_RANLIB}")
set(GCC_LTO_CFLAGS "-flto -fno-fat-lto-objects -fuse-linker-plugin")
if(CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 11.4)
set(GCC_LTO_CFLAGS "-flto -fno-fat-lto-objects -fuse-linker-plugin")
else()
set(GCC_LTO_CFLAGS "-flto=auto -fno-fat-lto-objects -fuse-linker-plugin")
endif()
set(GCC_LTO_AVAILABLE TRUE)
message(STATUS "Link-Time Optimization by GCC is available")
else()
Expand Down Expand Up @@ -541,13 +545,21 @@ if(CMAKE_COMPILER_IS_CLANG)
if(regexp_valid)
string(REGEX REPLACE "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs})
string(REPLACE ":" ";" list "${list}")
set(libs_extra_subdirs "lib;../lib;lib64;../lib64;lib32;../lib32")
foreach(dir IN LISTS list)
get_filename_component(dir "${dir}" REALPATH)
if(dir MATCHES ".*llvm.*" OR dir MATCHES ".*clang.*")
list(APPEND clang_bindirs "${dir}")
set(list_suffix "")
else()
list(APPEND clang_bindirs_x "${dir}")
set(list_suffix "_x")
endif()
list(APPEND clang_bindirs${list_suffix} "${dir}")
foreach(subdir IN LISTS libs_extra_subdirs)
get_filename_component(subdir "${dir}/${subdir}" REALPATH)
if(EXISTS "${subdir}")
list(APPEND clang_libdirs${list_suffix} "${subdir}")
endif()
endforeach()
endforeach()
list(APPEND clang_bindirs "${clang_bindirs_x}")
list(REMOVE_DUPLICATES clang_bindirs)
Expand All @@ -559,10 +571,11 @@ if(CMAKE_COMPILER_IS_CLANG)
foreach(dir IN LISTS list)
get_filename_component(dir "${dir}" REALPATH)
if(dir MATCHES ".*llvm.*" OR dir MATCHES ".*clang.*")
list(APPEND clang_libdirs "${dir}")
set(list_suffix "")
else()
list(APPEND clang_libdirs_x "${dir}")
set(list_suffix "_x")
endif()
list(APPEND clang_libdirs${list_suffix} "${dir}")
endforeach()
list(APPEND clang_libdirs "${clang_libdirs_x}")
list(REMOVE_DUPLICATES clang_libdirs)
Expand Down Expand Up @@ -656,7 +669,7 @@ if(CMAKE_COMPILER_IS_CLANG)
AND CMAKE_CLANG_NM
AND CMAKE_CLANG_RANLIB
AND ((CLANG_LTO_PLUGIN AND CMAKE_LD_GOLD)
OR (CMAKE_CLANG_LD AND NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
OR CMAKE_CLANG_LD
OR APPLE))
if(ANDROID AND CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 12)
set(CLANG_LTO_AVAILABLE FALSE)
Expand Down
Loading
Loading