Modern Judy Arrays & High-Performance Digital Tree Engine
Clean-room pure-Rust implementation of digital trees modernized for modern 64-bit microarchitectures with zero-allocation immediates, SWAR/SIMD vectorization, and lock-free OCC reader concurrency.
Partitioning digital trees by key expanse, rather than population.
Expanse is the Judy design's own defining term — so central that the published descriptions stop to define it before anything else, and use it as the precise contrast with population-partitioned trees (B-trees, binary trees):
“Expanse, population, and density are not commonly used terms in tree search literature, so let's define them here: Expanse is a range of possible keys […]”
— Doug Baskins, A 10-Minute Description of How Judy Arrays Work and Why They Are So Fast (2002)
“A digital tree divides up the population (index set) uniformly by expanse (dividing and redividing the initial expanse evenly), while other methods, such as b-trees, divide up the population by the distribution of the population itself.”
— Alan Silverstein, Judy IV Shop Manual (2002), “Digital Trees”
Naming the project after the underlying mechanism honors the algorithm itself without inheriting legacy C codebase baggage. Expanse is developed with strict clean-room discipline: zero exposure to LGPL source code, adhering exclusively to published design specifications and black-box differential test suites.
Core Engine
Architectural Highlights
Engineered for cache-line density, hardware SIMD lanes, and lock-free multi-core throughput.
⚡
Zero-Alloc Immediates
Up to 7 keys in sets and up to 3 key-value pairs in maps are packed directly inside tagged 64-bit edge words, bypassing heap allocation entirely for small collections.
⚙
Adaptive Compression Ladder
Trie branches dynamically morph between Linear leaves (sorted key arrays), Bitmap leaves (64-bit subexpanse bitboards), and full uncompressed 256-way digital branches.
🚀
Lock-Free OCC Concurrency
SyncExpanseMap and SyncExpanseSet employ epoch-based optimistic concurrency control (OCC). Readers perform lock-free traversals with zero reader-lock cache-line bouncing.
🎯
SIMD & SWAR Acceleration
Search kernels utilize vector instructions (AVX2, AVX-512, ARM NEON) with bitwise SWAR fallbacks, scanning linear leaves in single clock cycles.
📦
glibc-hwcaps Multi-Arch
Debian and RPM packages provide optimized runtime libraries automatically selected by the dynamic loader for x86-64-v2, v3 (AVX2), and v4 (AVX-512).
🔗
Drop-in Judy C ABI Parity
Provides 100% C ABI compatibility with stock libjudy (Judy1, JudyL, JudySL, JudyHS) alongside modern, type-safe expanse_* C interfaces.
🌱
32-Bit Embedded (#![no_std])
Compact 8-byte Edge32 layout saving 50% structural SRAM on ARM Cortex-M and RISC-V RV32 microcontrollers, with 32-byte cache alignment and zero-alloc inlined payloads.
Explore the Interactive Data Visualizer
Inspect tagged pointer layouts, simulate dynamic compression transitions across the ladder, and step through branch bitboard operations in real-time.
import { ExpanseMap, ExpanseSet, ExpanseStrMap, ExpanseBlobMap } from '@orieg/expanse';
// Integer map with BigInt key support
const map = new ExpanseMap();
map.set(42n, 100n);
console.log(map.get(42n)); // 100n
// Off-heap blob map with Buffer / Uint8Array slices & hot metadata
const blobs = new ExpanseBlobMap();
blobs.set(1001n, Buffer.from("payload bytes"), 42);
const entry = blobs.getWithMeta(1001n);
console.log(entry?.payload.toString()); // "payload bytes"
Install the official .NET package from NuGet (multi-targeting .NET 8.0 & 9.0 with SafeHandle zero-GC memory safety):
dotnet add package OriEg.Expanse
Usage example in C#:
using OriEg.Expanse;
// High-speed integer word map
using var map = new ExpanseMap();
map[42] = 100;
if (map.TryGet(42, out var val)) {
Console.WriteLine($"Found: {val}");
}
// Off-heap blob map with zero-copy ReadOnlySpan<byte> views
using var blobs = new ExpanseBlobMap();
blobs.Set(1001, "Hello .NET"u8, hotMeta: 1);
if (blobs.TryGet(1001, out var payload, out var meta)) {
Console.WriteLine($"Payload: {System.Text.Encoding.UTF8.GetString(payload)}");
}
Header-only modern C++20 RAII container wrapper (include/expanse.hpp):