VDB 1.0.2.2 released

1. Overview

VDB 1.0.2.2 is a maintenance” release : On the basis of 1.0.2.1, a round of systematic equivalent refactoring and modernization has been done within the engine, The goal is to reduce the amount of code, eliminate duplication, and unify the error handling paradigm ,Keep external interfaces, disk layout, and runtime behavior completely unchanged. .

This version is mainly based on equivalent refactoring.No new features; External interfaces, disk layout, and runtime behavior are guaranteed to be exactly the same as 1.0.2.1. All changes are fully validated by the regression net.

2. Changes

All are equivalent refactors , Categorized by topic :

1. The engine error field is unified as std::expected

Propagate errors across functions within the engine from int Return code + manual check , gradually converge to std::expected<T, int>(vdb::detail::result<T>) Single subchain.VDB_TRY / VDB_TRYE / VDB_UNWRAP Macros make error propagation a line, eliminates a lot of hidden dangers of forgetting to check rc” without changing any error code values.

A little explanation of why “ use macros instead of templates”. The essence of error propagation is “ error is advanced from the caller function return”, And the function/template of C++ is written no matter how it is written return It can only return itself, and cannot be injected into the scope of the caller - this is the hard boundary of language capabilities. ?, Swift for try Solve the error propagation expressions native to the C++ language have not yet entered the standard. Therefore, without the help of macros, the only way to get rid of the boilerplate is to rewrite each function body into std::expected The monad subchain(and_then / transform / or_else), But that would make all subsequent statements indented into nested lambdas, Greatly change the shape and number of lines of the code , also deviated from the scope of this “ equivalent refactoring, control flow invariant”. Comprehensive trade-offs , Keeping these three internal macros is the safest choice at present.

These macros areDedicated inside the engine, no pollution from the outside:VDB_TRY / VDB_TRYE / VDB_UNWRAP( and vdb_assert) All at the public entrance vdb.hpp The end of the #undef, Only in vdb/engine/ With vdb/detail/ Internal expansion , does not leak the namespace of the library consumer ⼌ nor does it conflict with the identifier of the same name in the user code. The biggest drawback of macros ( pollute the scope of the user ) is eliminated here , The remaining cost ⼈ Failure to break points in the macro, parameters are not valued ⼉ have minimal impact on the pure error propagation scenario.

2. Equivalent contraction of all ethnic groups

Removed duplication and tightened control flow have been rewritten for each subsystem of the engine.

  • Bridging layer(dbi_open Single scan,drop Cycle tightening)
  • Cursor family(cursor_step Templated merge cursor_next / cursor_prev)
  • B+ tree balance split family
  • rpage / txn / env / reader Ethnic

3. Modern C++ improvements

  • std::ranges Replace Handwriting Loops(find / sort / erase_if etc.
  • std::start_lifetime_as Specification of the object lifecycle of unconstructed storage
  • concept Constraint tightening template signatures
  • expected Single subchain(transform / and_then / or_else) Alternative Nested Branches

4. Dead code removal and single call point inline

Removed internal functions that are no longer referenced ( malloc_bytes,page_crypto_state::integrity()), Inline callback of a small function with only one call point.

5. cursor_op Double enumeration deduplication

Previously, the public layer vdb::cursor_op With the engine layer VDB_cursor_op are two sets of enumerations with the same value , api.hpp The static_assert Value-by-value alignment. This time the engine layer enumeration is removed to make the public layer cursor_op BecomeSingle source of truth-- The engine uses it directly, no longer maintains duplicate definitions, and no longer needs that set of alignment assertions(docs/abi.md Synchronous updates have been made).

6. Loose leaf collection draw collect_loose_into

Put freelist_save In “ traverse the loose page linked list → collect page numbers → clear the linked list ” repeated logic extraction helper, for the path for the direct merge of loose pages(B paragraph). Note that the loose page is removed from the dirty list and the path of the page memory ⼈A paragraph) must be read before release - because VDB_page The mp_pgno Linked list pointer with idle cache mp_next Yes, the release will override the page number, see section 5, for details.

7. Others

  • Fix IntelliSense pair expected False positives of assignments do not affect compilation and operation.

3. Source code slimming

Indicators1.0.2.11.0.2.2Variation
vdb/ Number of valid code lines( Exclude empty lines and comments)1198411487−497(−4.1%)
git diff net number of lines( with empty lines/comments)——−504

The changes are focused on vdb/engine/engine.hpp,vdb/detail/vdb_internal.hpp,vdb/engine/api.hpp, Public Head(handles.hpp / types.hpp / flags.hpp / callbacks.hpp) No change in signature.

4. Verification results

Verification itemsResultsEnvironment
Compilation(C++23 / C++26)ByWSL openSUSE + Cygwin
ctest( 13 items )13/13 passing(vdb_concurrency By Design SKIP)WSL+Cygwin
vdb_golden( Byte-by-byte comparison data.vdb)Through ,SHA and ABI-MANIFEST.txt ConsistentWSL+Cygwin
vdb_compatibility( Old golden Reopen)ByWSL+Cygwin
vdb_abi_contract / vdb_abi_manifestByWSL+Cygwin
vdb_odr_multi_tuByWSL+Cygwin
vdb_fault_paths / vdb_callbacks / vdb_multi_ops / vdb_env_presizeByWSL+Cygwin
Full Baseline Regression Net(5 Patterns)5/5 passesCygwin

baseline regression network must be run under Cygwin(WSL's mmap/filesystem timing will cause the spill mode of the db Drift between hash runs is an environmental difference and is not related to code.

5. Compatibility

  • Public APIs / ABIs: No change(vdb_abi_contract / vdb_abi_manifest Pass ).
  • Disk format: No change(vdb_golden / vdb_compatibility Via,data.vdb byte consistency).
  • Databases created in 1.0.2.1 and earlier can be opened directly with 1.0.2.2 and vice versa.
  • Upgrades do not require migration or code changes.

Related links

Leave a Comment