Crates.io | brie-tree |
lib.rs | brie-tree |
version | 0.1.2 |
created_at | 2025-06-13 23:29:37.168769+00 |
updated_at | 2025-07-13 02:19:36.566912+00 |
description | A fast B+ Tree implementation that uses integer keys |
homepage | |
repository | https://github.com/Amanieu/brie-tree |
max_upload_size | |
id | 1711977 |
size | 404,612 |
A fast B+ Tree implementation that uses integer keys.
The API is similar to the standard library's BTreeMap
with some significant
differences:
BTreeMap
.BTree
can optionally be used as a multi-map and hold duplicate keys.BTreeKey
trait.Ord
implementation of the keys.The data structure design is based on the B- Tree by Sergey Slotin, but has been significantly extended.
Restricting keys to integer types is what allows this crate to be so much faster than the standard library. Notably, this allows searching within B-Tree nodes to be done using an efficient SIMD search.
Currently, SIMD optimizations are implemented for the following targets:
SIMD instruction set | Target feature flags to use |
---|---|
x86 SSE2 (x86-64-v1) | +sse2 (enabled by default on x86-64) |
x86 SSE4.2 (x86-64-v2) | +sse4.2,+popcnt |
x86 AVX2 (x86-64-v3) | +avx2,+popcnt |
x86 AVX512 (x86-64-v4) | +avx512bw,+popcnt |
AArch64 NEON | +neon (enabled by default on AArch64) |
AArch64 SVE | +sve |
RISC-V RVV | +v |
In the absence of any of these, there is a fallback implementation using an unrolled binary search.
This crate doesn't use dynamic dispatch since the cost of dispatch would
outweigh the performance benefits of a faster implementation. Instead, the
target features must be enabled at compile-time by passing them to
-C target-feature=
:
RUSTFLAGS="-C target-feature=+avx2,+popcnt" cargo build --release
These benchmarks compare the standard library's BTreeMap
with this crate's
BTree
. The benchmarks were run on a Ryzen 9 3950X system.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.