libart++
The adaptive radix tree map for modern C++.
std::map's interface, with cost counted in the unit that actually
matters: at most one cold cacheline per level, and levels bounded by your
key's bytes — never by your data's size.
header-only
C++20
zero dependencies
allocator-aware · PMR
fuzzed vs std::map
fault-injection tested
// the interface you already know
#include <artpp/map.hpp>
artpp::map<std::string, uint64_t> m; // takes string_view args: no temp strings
m.insert("alpha", 1);
m.try_emplace("beta", 2); // present → untouched, nothing constructed
if (auto it = m.find(user_input); it != m.end())
use(it->first, it->second);
for (const auto& [key, value] : m) // ascending key order, always
process(key, value);
Count cachelines, not comparisons
A lookup's real cost is its cold cacheline loads — every other
instruction hides behind them. Big-O in comparisons flatters comparison trees;
measured in cachelines, a B-tree lookup is O(log n) dependent misses.
libart++ is engineered so each level of descent costs at most ONE cold line —
and the level count is bounded by your key's bytes, not your data's size.
Headerless dispatch
The node's kind rides in the tagged pointer, so descent knows how to route
before the node arrives: no header line load before the child slot load. One line
per hop is the contract, not the goal.
Prefixes live in the header line
A compressed run is stored inside the cacheline the node already owns; the
pointer tag hints when it must be read, and a prefix-free node never touches it. A
separate prefix node exists only when the run does not fit the node's header line
(7 bytes in a sparse router, 63 in a full one) — overflow, not the default. Path
compression at zero extra lines.
Terminals cost almost nothing
Values ≤5 bytes pack inline in the handle bits — zero lines. A small leaf
can live inside the routing setlist's own cacheline (no separate load at all).
Anything else sits in a dedicated 16-byte-aligned terminal region — a leaf is
pure payload, so it gets exactly what it needs, not a 128-byte line.
Levels collapse adaptively
Sparse byte levels fuse: wide stems consume two key bytes per line, buckets pack
whole key tails into one 4-line page, dense spans direct-index. The tree spends
lines where your data's entropy actually is.
Measured on two machines
One templated benchmark engine drives every contestant through
identical code — same keys, same op sequence, same checksums. Upstream
libart is vendored;
absl::btree_map and std::map use heterogeneous lookup.
The numbers are for release 0.1.0, measured 2026-11-28 on an Apple M5 Max and on an
x86-64 Linux server (AMD EPYC-Turin). Where artpp is slower than a baseline, the
charts and tables show it and the text says so.
Reproduce with -DARTPP_BENCHMARKS=ON.
1.14–1.97×
point lookups against libart on the Apple M5 Max: faster on all four workloads with both allocators
0.68–3.49×
point lookups against libart on the x86-64 server: 1.06–1.11× dictionary, 0.96–1.05× clustered, 1.44–3.49× sequential, and 0.68–0.78× on uniform random integers, which is slower
4.24–4.77×
faster lookups than unodb on 32-byte keys, both machines; inserts 2.16–4.01×, lower_bound 1.94–4.90×
0.87–3.47×
point lookups against absl::btree_map across both machines (M5 1.72–3.13×, x86 0.87–3.47×; below 1 is slower)
Point lookups (present keys, random order)
Left: Apple M5 Max. Right: the x86-64 server. The charts' artpp::map row is the bundled line_pool allocator, artpp::map<buckets> is mode::buckets on the same allocator, and the std::allocator row is the map with no setup. Bars are the median of 7 runs. Point lookups against libart: on the Apple M5 Max 1.14–1.97× faster on all four workloads with both allocators; on the x86-64 server 1.06–1.11× on dictionary words, 0.96–1.05× on clustered strings, 1.44–3.49× on sequential integers and 0.68–0.78× on uniform random integers, which is slower. Against the comparison-based maps, point lookups are 1.72–3.13× absl::btree_map and 2.15–6.83× std::map on the M5, and 0.87–3.47× and 1.79–8.05× on the x86-64 server (below 1 is slower: uniform random integers with std::allocator). On uniform random integers line_pool lookups are 1.03× the std::allocator map's speed on the M5 and 1.18× on the x86-64 server: line_pool is not slower on uniform keys on either machine. The cause of the difference between the two machines is not yet known; huge pages were tried on the x86-64 server and did not help. The table gives every ratio; a range in parentheses is the spread over the runs where it exceeds 10 %.
| workload | allocator | M5 ns | M5 vs libart | M5 vs absl::btree_map | M5 vs std::map | x86 ns | x86 vs libart | x86 vs absl::btree_map | x86 vs std::map |
| dictionary words | line_pool | 110 (103–119) | 1.14× (1.04–1.18) | 1.80× | 2.19× (1.88–2.44) | 87.8 | 1.11× | 2.42× | 2.73× |
| std::allocator | 111 | 1.14× | 1.72× (1.66–2.00) | 2.15× (2.07–2.32) | 91.7 | 1.06× | 2.33× | 2.63× |
| clustered strings | line_pool | 129 | 1.35× | 2.42× | 3.85× (3.61–4.14) | 320 (320–356) | 1.05× (0.95–1.06) | 3.02× (2.77–3.08) | 4.33× (3.92–4.39) |
| std::allocator | 129 (126–141) | 1.34× | 2.37× | 3.83× (3.65–4.04) | 351 | 0.96× | 2.80× | 3.96× |
uniform u64 | line_pool | 41.5 | 1.27× | 2.20× (2.04–2.64) | 4.68× | 107 (106–143) | 0.78× (0.61–0.82) | 1.02× (0.76–1.05) | 2.09× (1.59–3.24) |
| std::allocator | 43.2 | 1.24× | 2.13× (2.00–2.64) | 4.54× (4.46–4.93) | 127 (123–137) | 0.68× (0.61–0.70) | 0.87× (0.80–0.89) | 1.79× (1.71–2.54) |
sequential u64 | line_pool | 24.4 (23.7–26.9) | 1.97× | 3.13× (2.92–3.45) | 6.83× (6.28–7.03) | 28.3 (27.4–42.7) | 3.49× (2.44–3.83) | 3.47× (2.31–3.64) | 8.05× (5.28–9.17) |
| std::allocator | 33.1 (31.3–36.8) | 1.44× (1.34–1.55) | 2.40× (2.21–2.53) | 5.03× (4.60–5.43) | 69.1 | 1.44× | 1.43× | 3.29× (3.26–3.64) |
Where artpp is slower on lookups (every cell below 1):
- Lookups (hit) against libart: Apple M5 Max: none; AMD EPYC-Turin: clustered strings (0.96×
std::allocator); uniform u64 (0.78× line_pool, 0.68× std::allocator).
- Lookups (hit) against
absl::btree_map: Apple M5 Max: none; AMD EPYC-Turin: uniform u64 (0.87× std::allocator).
- Lookups (hit) against
std::map: Apple M5 Max: none; AMD EPYC-Turin: none.
lower_bound (position at the next-greater key)
Positioning at the next-greater key is the query an ordered map adds over a hash map. libart has no such call (shown as unsupported). Against absl::btree_map, artpp's lower_bound is 0.87–1.67× its speed on the M5 and 0.49–2.52× on the x86-64 server, depending on the workload: faster on clustered strings and sequential integers on both machines, slower on uniform random integers on both. Where artpp is slower (ratios are artpp's speed relative to the baseline; the README has the full table):
lower_bound against absl::btree_map: Apple M5 Max: dictionary words (0.96× line_pool, 0.91× std::allocator); uniform u64 (0.89× line_pool, 0.87× std::allocator); AMD EPYC-Turin: uniform u64 (0.62× line_pool, 0.49× std::allocator).
Inserts (bulk build)
Both allocators are on the charts. The same tree on line_pool builds 1.14–1.37× as fast as on std::allocator on the M5 and 1.17–1.45× on the x86-64 server. Against libart the result depends on the keys: dictionary words build more slowly on both machines, sequential integers faster on both. Where artpp is slower (ratios are artpp's speed relative to the baseline; the README has the full table):
- Inserts against libart: Apple M5 Max: dictionary words (0.87×
line_pool, 0.70× std::allocator); clustered strings (0.99× std::allocator); uniform u64 (0.91× std::allocator); AMD EPYC-Turin: dictionary words (0.74× line_pool, 0.51× std::allocator); clustered strings (0.92× line_pool, 0.72× std::allocator).
- Inserts against
absl::btree_map: Apple M5 Max: dictionary words (0.78× line_pool, 0.63× std::allocator); AMD EPYC-Turin: dictionary words (0.82× std::allocator).
Ordered scans (full in-order traversal)
Full in-order traversals (artpp through for_each_value). In the default mode artpp scans more slowly than absl::btree_map in 16 of 16 cells. mode::buckets stores key tails in packed pages: on dictionary words it scans 2.62–3.10× as fast as the default mode, and on clustered strings 1.10–1.57× as fast as absl::btree_map; on sequential integers it is slower than the default mode. Where artpp is slower (ratios are artpp's speed relative to the baseline; the README has the full table):
- Ordered scans against libart: Apple M5 Max: dictionary words (0.75×
line_pool, 0.77× std::allocator); clustered strings (0.88× line_pool, 0.84× std::allocator); uniform u64 (0.86× line_pool, 0.71× std::allocator); sequential u64 (0.86× std::allocator); AMD EPYC-Turin: dictionary words (0.98× line_pool, 0.93× std::allocator); clustered strings (0.80× std::allocator); uniform u64 (0.85× line_pool, 0.72× std::allocator); sequential u64 (0.91× std::allocator).
- Ordered scans against
absl::btree_map: Apple M5 Max: dictionary words (0.12× line_pool, 0.13× std::allocator); clustered strings (0.50× line_pool, 0.49× std::allocator); uniform u64 (0.15× line_pool, 0.13× std::allocator); sequential u64 (0.41× line_pool, 0.35× std::allocator); AMD EPYC-Turin: dictionary words (0.24× line_pool, 0.22× std::allocator); clustered strings (0.64× line_pool, 0.51× std::allocator); uniform u64 (0.06× line_pool, 0.05× std::allocator); sequential u64 (0.69× line_pool, 0.26× std::allocator).
Methodology: measured 2026-11-28 on the release code (390e25c). M5: Apple M5 Max, macOS 26.3, Apple clang 17, -O3; the machine was in use (load averages 2.4–4.8 during the main suite; the three 32-byte-key runs started at 2.9, 44.2, 2.9). x86: AMD EPYC-Turin virtual machine (16 vCPUs), x86-64 Linux, clang++ 20, libstdc++ 15, -O3, pinned to one core; load average under 2.5. The main suite ran 7 times per machine: times are medians, ratios are medians of the per-run ratios. The 32-byte-key numbers are the minimum over the runs. Workloads: dictionary words (each machine's own /usr/share/dict/words: 236k words on the M5, 104k on the x86 server, so the dictionary rows compare the contestants on one machine and not the two machines with each other), 885k clustered strings, 1M uniform random and 1M sequential uint64_t (typed APIs; libart receives the identical big-endian bytes). Data: results-m5.csv, results-x86.csv, raw runs and the script that produced every number on this page · engine: bench/engine.hpp. A regression gate compares the working tree with a baseline commit on this same benchmark (interleaved runs, paired ratios); it is run by hand on a quiet machine, not in CI.
32-byte keys, and unodb
Many real keys do not fit in a CPU register: hashes, UUIDs, composite
tuples. This benchmark stores random 32-byte keys and adds two contestants to
the field: unodb, the other
general-purpose C++ ART, and std::unordered_map.
Random 32-byte keys, 10M of them, each container built and measured on its own; nanoseconds per operation (per element for scans), minimum over the runs (3 on the M5, 2 on the x86 server). unodb ran on the identical keys as unodb::db<unodb::key_view, std::uint64_t>. art_map is absent: the benchmark source records that it does not compile for a key longer than 16 bytes.
| ns per op | M5 insert | M5 hit | M5 scan | M5 lower_bound | x86 insert | x86 hit | x86 scan | x86 lower_bound |
artpp::map (line_pool) | 111.6 | 68.2 | 17.15 | 119.6 | 235.9 | 211.4 | 59.72 | 361.2 |
artpp::map (std::allocator) | 152.0 | 68.3 | 18.13 | 127.8 | 381.3 | 216.9 | 55.04 | 380.5 |
| libart | 140.4 | 92.8 | 13.03 | n/a | 665.3 | 163.4 | 41.99 | n/a |
| unodb | 447.2 | 325.0 | 212.26 | 585.9 | 823.6 | 920.7 | 309.24 | 738.6 |
absl::btree_map | 1040.8 | 1071.3 | 10.49 | 1034.1 | 1914.0 | 1888.0 | 43.33 | 2049.6 |
std::map | 1378.8 | 1387.8 | 72.93 | 1393.6 | 2123.7 | 3274.5 | 210.11 | 3377.4 |
std::unordered_map | 202.2 | 91.7 | n/a | n/a | 1092.9 | 280.6 | n/a | n/a |
How many times faster artpp is (below 1 is slower):
| artpp allocator | times faster than | M5 insert | M5 hit | M5 scan | M5 lower_bound | x86 insert | x86 hit | x86 scan | x86 lower_bound |
line_pool | unodb | 4.01× | 4.77× | 12.38× | 4.90× | 3.49× | 4.36× | 5.18× | 2.04× |
| libart | 1.26× | 1.36× | 0.76× | n/a | 2.82× | 0.77× | 0.70× | n/a |
| absl::btree_map | 9.33× | 15.71× | 0.61× | 8.65× | 8.11× | 8.93× | 0.73× | 5.67× |
| std::map | 12.35× | 20.35× | 4.25× | 11.65× | 9.00× | 15.49× | 3.52× | 9.35× |
| std::unordered_map | 1.81× | 1.34× | n/a | n/a | 4.63× | 1.33× | n/a | n/a |
std::allocator | unodb | 2.94× | 4.76× | 11.71× | 4.58× | 2.16× | 4.24× | 5.62× | 1.94× |
| libart | 0.92× | 1.36× | 0.72× | n/a | 1.74× | 0.75× | 0.76× | n/a |
| absl::btree_map | 6.85× | 15.69× | 0.58× | 8.09× | 5.02× | 8.70× | 0.79× | 5.39× |
| std::map | 9.07× | 20.32× | 4.02× | 10.90× | 5.57× | 15.10× | 3.82× | 8.88× |
| std::unordered_map | 1.33× | 1.34× | n/a | n/a | 2.87× | 1.29× | n/a | n/a |
Against unodb, on random 32-byte keys, 10M of them, lookups are 4.76–4.77× (M5) and 4.24–4.36× (x86) faster, inserts 2.94–4.01× (M5) and 2.16–3.49× (x86), ordered scans 11.71–12.38× (M5) and 5.18–5.62× (x86) and lower_bound 4.58–4.90× (M5) and 1.94–2.04× (x86); the ranges cover both allocators. Against libart, lookups are 1.36× its speed on the M5 and 0.75–0.77× on the x86-64 server, where artpp is slower. Ordered scans are slower than libart's and absl::btree_map's on both machines.
Earlier measurements, not repeated for this release. Until 0.1.0 this page
showed runs from June 2026 on an Apple M5 Max, made with earlier code: the same
32-byte keys scaled from 1M to 100M keys, and a variant with fixed
std::array keys. They were not measured again for 0.1.0, so their charts
and numbers have been taken off the page. They remain in the repository history
(docs/charts/buffer_*.svg, docs/charts/array_*.svg and
docs/gen_buffer_charts.py before the 0.1.0 release commit).
In a file, against Boost.MultiIndex
A map on a file-backed line_pool is stored in a file and reopened
without a rebuild. The usual C++ way to keep an ordered container in a mapped file is
boost::multi_index_container in a Boost.Interprocess managed mapped file, so
that is the comparison. Boost.MultiIndex offers what artpp does not: several indexes over
one element, elements of any offset-pointer-aware type, MSVC. artpp validates and stamps
its store and refuses one it cannot trust; Boost uses the segment as it finds it. The
README
has the full comparison.
artpp_bench_filebacked (bench/bench_filebacked.cpp) stores the four workloads of the main suite, the same keys in the same order, in a file with each contestant, each in its own new directory: 3 runs per machine, one process at a time (load averages before the runs: 1.18, 2.88, 2.19 on the M5, 1.26, 1.68, 1.76 on the x86-64 server); times are the median of the runs and "artpp faster" is the median of the per-run ratios, below 1 meaning slower. The stores were on local disks (APFS on the M5, ext4 on the x86-64 server). The page cache was warm throughout: the benchmark reopens a store moments after writing it, so the reopen figures measure mapping and validation, not reading from disk.
| op | workload | M5 artpp ns | M5 Boost.MultiIndex ns | M5 artpp faster | x86 artpp ns | x86 Boost.MultiIndex ns | x86 artpp faster |
| insert | dictionary words | 95.1 | 206 | 2.16× | 124 | 418 | 3.35× |
| clustered strings | 174 | 524 | 3.08× | 405 | 978 | 2.41× |
| uniform u64 | 50.0 | 465 | 9.32× | 98.6 | 636 | 6.05× |
| sequential u64 | 10.8 | 238 | 22.03× | 24.1 | 356 | 14.93× |
| hit | dictionary words | 111 | 287 | 2.63× | 87.3 | 230 | 2.63× |
| clustered strings | 124 | 534 | 4.28× | 322 | 917 | 2.86× |
| uniform u64 | 41.0 | 476 | 12.18× | 119 | 595 | 4.98× |
| sequential u64 | 23.3 | 408 | 16.99× | 27.8 | 892 | 31.63× |
| miss | dictionary words | 39.5 | 93.4 | 2.36× | 35.4 | 91.9 | 2.60× |
| clustered strings | 96.2 | 457 | 4.75× | 201 | 571 | 2.84× |
| uniform u64 | 16.1 | 467 | 29.20× | 28.1 | 549 | 19.62× |
| sequential u64 | 5.3 | 73.2 | 13.77× | 8.7 | 115 | 13.24× |
lower_bound | dictionary words | 82.5 | 84.8 | 1.03× | 81.5 | 106 | 1.30× |
| clustered strings | 194 | 444 | 2.30× | 372 | 554 | 1.48× |
| uniform u64 | 99.0 | 488 | 4.92× | 196 | 554 | 3.02× |
| sequential u64 | 16.6 | 72.8 | 4.38× | 22.3 | 114 | 5.14× |
| scan | dictionary words | 8.3 | 9.8 | 1.15× | 8.3 | 9.3 | 1.11× |
| clustered strings | 18.0 | 100 | 5.74× | 38.9 | 162 | 4.17× |
| uniform u64 | 15.4 | 88.2 | 6.14× | 56.0 | 140 | 2.49× |
| sequential u64 | 1.6 | 8.0 | 4.81× | 2.3 | 8.2 | 3.50× |
| erase (after reopen) | dictionary words | 199 | 554 | 2.70× | 160 | 598 | 3.75× |
| clustered strings | 275 | 1182 | 4.29× | 600 | 1726 | 2.88× |
| uniform u64 | 123 | 932 | 7.55× | 326 | 1410 | 4.32× |
| sequential u64 | 63.6 | 781 | 12.28× | 113 | 1559 | 13.74× |
| hit after reopen, first pass | dictionary words | 121 | 300 | 2.53× | 95.3 | 237 | 2.48× |
| clustered strings | 131 | 593 | 4.52× | 349 | 893 | 2.72× |
| uniform u64 | 44.6 | 499 | 11.53× | 124 | 657 | 5.65× |
| sequential u64 | 32.3 | 427 | 13.22× | 33.0 | 900 | 27.30× |
| hit after reopen | dictionary words | 107 | 265 | 2.48× | 87.3 | 230 | 2.61× |
| clustered strings | 122 | 575 | 4.73× | 317 | 914 | 2.88× |
| uniform u64 | 40.4 | 500 | 12.74× | 111 | 617 | 5.83× |
| sequential u64 | 21.3 | 417 | 19.44× | 27.8 | 873 | 30.97× |
Durability and reopening (a range in parentheses is the minimum and maximum over the runs). artpp's checkpoint() records the tree and forces nothing to disk; Boost's flush() is an asynchronous msync; "to disk" adds a synchronous msync for both; reopen is the time from opening the store to the first lookup's result.
| workload | machine | artpp checkpoint() µs | Boost flush() µs | artpp to disk ms | Boost to disk ms | artpp close µs | Boost close µs | artpp reopen µs | Boost reopen µs |
| dictionary words | M5 | 0.9 (0.8–1.2) | 1411 (1345–4678) | 3.11 (3.09–3.23) | 1.46 (1.39–4.73) | 250 (239–278) | 108 (105–152) | 130 (113–156) | 49 (38–52) |
| x86 | 1.6 (1.6–1.6) | 2.5 (2.1–2.9) | 4.77 (3.52–5.22) | 3.31 (3.16–3.96) | 446 (114–493) | 115 (100–528) | 39 (36–48) | 30 (27–33) |
| clustered strings | M5 | 1.1 (0.8–1.2) | 4489 (4462–6087) | 8.46 (7.71–10.78) | 4.66 (4.64–6.20) | 390 (390–488) | 346 (294–375) | 146 (146–147) | 59 (58–62) |
| x86 | 1.9 (1.8–2.1) | 4.1 (3.2–4.2) | 19.76 (16.27–21.80) | 19.35 (18.89–19.53) | 2843 (700–3569) | 914 (500–961) | 78 (70–94) | 35 (35–51) |
uniform u64 | M5 | 0.9 (0.9–1.0) | 3826 (3747–3892) | 9.81 (9.77–9.89) | 4.00 (3.97–4.03) | 684 (640–733) | 343 (312–400) | 143 (119–158) | 66 (65–66) |
| x86 | 2.5 (2.2–3.0) | 4.3 (4.0–5.0) | 22.43 (19.03–25.38) | 17.54 (14.17–18.76) | 4295 (838–4335) | 966 (904–1022) | 75 (62–82) | 61 (50–64) |
sequential u64 | M5 | 0.9 (0.8–1.2) | 3851 (3704–4160) | 4.03 (3.88–4.65) | 4.04 (3.81–4.48) | 374 (352–488) | 361 (236–473) | 132 (130–141) | 53 (48–64) |
| x86 | 2.4 (2.3–2.5) | 4.6 (3.9–4.7) | 12.42 (9.39–12.53) | 18.26 (17.40–18.54) | 1609 (294–1743) | 886 (851–912) | 58 (50–76) | 43 (39–53) |
Space: bytes allocated per key, and the size on disk.
| workload | machine | keys | artpp used B/key | Boost used B/key | artpp files MiB | artpp on disk MiB | Boost on disk MiB |
| dictionary words | M5 | 235,976 | 84.8 | 80.0 | 20.1 | 20.1 | 18.0 |
| x86 | 104,334 | 84.9 | 80.0 | 12.1 | 8.4 | 8.0 |
| clustered strings | M5 | 884,615 | 66.4 | 80.0 | 56.1 | 56.1 | 67.5 |
| x86 | 884,615 | 66.4 | 80.0 | 56.1 | 55.9 | 68.0 |
uniform u64 | M5 | 1,000,000 | 67.0 | 56.0 | 68.1 | 68.1 | 53.4 |
| x86 | 1,000,000 | 66.9 | 64.0 | 68.1 | 63.7 | 62.0 |
sequential u64 | M5 | 1,000,000 | 26.2 | 56.0 | 28.1 | 28.1 | 53.4 |
| x86 | 1,000,000 | 26.2 | 64.0 | 28.1 | 24.9 | 62.0 |
Where artpp is behind Boost.MultiIndex:
- bytes used per key, artpp larger: M5 dictionary words (84.8 against 80.0 B/key), M5 uniform
u64 (67.0 against 56.0 B/key), x86 dictionary words (84.9 against 80.0 B/key), x86 uniform u64 (66.9 against 64.0 B/key).
- time to disk, artpp longer: M5 dictionary words, M5 clustered strings, M5 uniform
u64, x86 dictionary words, x86 clustered strings, x86 uniform u64.
- close, artpp longer: M5 dictionary words, M5 clustered strings, M5 uniform
u64, M5 sequential u64, x86 dictionary words, x86 clustered strings, x86 uniform u64, x86 sequential u64.
- reopen to first lookup, artpp longer: M5 dictionary words, M5 clustered strings, M5 uniform
u64, M5 sequential u64, x86 dictionary words, x86 clustered strings, x86 uniform u64, x86 sequential u64.
In short: against boost::multi_index_container with one ordered index in a Boost.Interprocess mapped file, on the four workloads of the main suite, lookups are 2.63–16.99× faster on the M5 and 2.63–31.63× on the x86-64 server, inserts 2.16–22.03× and 2.41–14.93×, lower_bound 1.03–4.92× and 1.30–5.14×. Boost reopens a store sooner (49–66 µs to the first lookup against artpp's 130–146 µs on the M5; 30–61 µs against 39–78 µs on the x86-64 server), closes it sooner, and needs fewer bytes per key on dictionary words and uniform integers (84.79–84.90 against 80.00–80.01 B/key; 66.88–66.97 against 56.00–64.00 B/key), where artpp needs fewer on clustered strings and sequential integers (66.37–66.39 against 80.00 B/key; 26.17 against 56.00–64.00 B/key). Boost.MultiIndex holds several indexes over one element, which artpp does not.
Compared with other radix trees
Three other adaptive radix trees are the reference points:
libart (C),
unodb (C++20) and
art_map (C++14). The measured
results first, then what each library can and cannot do. The
README
has the sources for every statement.
libart. Point lookups against libart: on the Apple M5 Max 1.14–1.97× faster on all four workloads with both allocators; on the x86-64 server 1.06–1.11× on dictionary words, 0.96–1.05× on clustered strings, 1.44–3.49× on sequential integers and 0.68–0.78× on uniform random integers, which is slower.
unodb. Measured single-threaded, on random 32-byte keys, 10M of them, lookups are 4.76–4.77× (M5) and 4.24–4.36× (x86) faster, inserts 2.94–4.01× (M5) and 2.16–3.49× (x86), ordered scans 11.71–12.38× (M5) and 5.18–5.62× (x86) and lower_bound 4.58–4.90× (M5) and 1.94–2.04× (x86); the ranges cover both allocators.
art_map. Not measured: its keys are limited to 16 bytes, so it cannot run the string or 32-byte workloads. No speed claim is made against it.
What the C++ API adds over libart
| libart (C) | libart++ (artpp::map) |
| Language | C: two files, about 800 lines; callable from C and from any
language with a C foreign function interface |
C++20, header-only, GCC or Clang |
| Interface | art_insert / art_search /
art_delete on byte pointers and lengths |
the std::map interface: find, at,
operator[], try_emplace, erase,
swap, ==; artpp::set for keys only |
| Keys | raw byte pointers + lengths; encoding is the caller's work |
string/string_view/integrals/byte vectors built in,
integers in numeric order; other types through key_codec, doubles
& reflected structs via psio |
| Values | void* — the caller owns the lifetime |
typed T: constructed in place, destroyed on erase,
moved on restructure, non-trivial and move-only types included; small ones
live inline in the pointer |
| Iteration | forward callbacks: art_iter,
art_iter_prefix |
bidirectional iterators, reverse ranges, erase(iterator),
range-for |
| Ordered queries | art_minimum / art_maximum;
no lower_bound |
lower_bound / upper_bound /
equal_range |
| Prefix iteration | art_iter_prefix, one call |
no dedicated call: lower_bound(prefix), then iterate while the
key starts with the prefix |
| Memory | calloc/free, fixed |
any standard allocator (PMR included); 4-byte indexed handles; mmap
file-backed pools; cross-pool moves as one memcpy |
| Small leaves | an allocated leaf per key |
a leaf that fits goes inside the routing node's cacheline (the 1-byte
inl header flags which children are inline) |
| Path compression | per-node prefix read with the header on
every hop |
prefix fused into the header line, read only when the pointer tag says
one exists |
| Failure handling | C: no exceptions, manual cleanup |
basic/strong guarantees stated per operation; fault injection at every
allocation point checks for leaks and double destruction |
| Deep trees | insert, delete, iteration and destroy recurse once per
level |
no operation's stack use grows with the depth of the tree |
| Structure | one fixed node ladder (4/16/48/256) |
selectable modes: buckets packs key tails into pages,
dense_tiers and wide_stems trade footprint against hop
depth — same semantics, same tests |
The C++ ARTs, by what they can hold
| library | keys | values | ordered access | concurrency | needs |
| artpp::map | byte strings up to 65535 bytes (a key may be a
prefix of another), integers, any type with a key_codec |
any move-constructible type |
iterators, lower_bound / upper_bound |
none (thread safety of a standard container) |
C++20, GCC or Clang; no dependencies |
| unodb | integral keys (its README: only uint64_t tested)
or key_view; no key may be a prefix of another, so text goes
through an encoder that truncates and pads |
byte spans, or a trivially copyable type |
scan callbacks: forward, reverse, from a key |
olc_db (concurrent), mutex_db |
C++20, Boost; SSE4.1 on Intel; GCC, Clang or MSVC |
| art_map | one integer of at most 16 bytes: no strings, no 32-byte
keys | not examined for this release, and not measured |
artpp is more general than art_map in the keys it holds, and more general than unodb in
its keys and values; unodb has concurrent trees and MSVC support, which artpp does not.
Nothing on this page says artpp is faster than art_map on the keys art_map supports:
that was not measured.
Engineered like a standard library component
The goal is a container you could submit for review: exact contracts,
systematic tests, documentation that states its limits.
Any key type
Strings, views, byte vectors, all integrals (numeric iteration order) built in.
With psio: doubles, reflected
structs, optionals, variants — one macro per type.
Structural modes
mode::buckets packs sparse key tails into cacheline pages (its
numbers are in the README's bucket-mode table); dense_tiers and wide_stems
trade footprint vs hop depth. Same semantics, tested identically.
Allocators, all the way down
Every node and value goes through your allocator — PMR works. Index-based
pool handles shrink branches to 4 bytes, back the map with an
mmap'd store directory, and make cross-pool moves a single memcpy.
Whole-tree ops use structure
Equality compares node-by-node (memcmp'd edges, no key materialization);
cross-allocator moves clone node-by-node — never key-by-key rebuilds.
Exception safety, tested
Every allocation point is fault-swept with throwing values and failing
allocators; leak, corruption, and double-destroy counters assert against a
std::map oracle.
Bidirectional, bounded, complete
lower_bound / upper_bound / equal_range,
reverse iteration, --end(), erase(iterator), structural
==, max_key_bytes guarded with length_error.
Thirty seconds of code
Integral keys iterate in numeric order
artpp::map<int64_t, std::string> m;
m.insert(-5, "negative"); // big-endian, sign-flipped
m.insert( 7, "positive"); // encoding: byte order ==
// numeric order, free
for (const auto& [k, v] : m) // → -5, then 7
log(k, v);
Floating-point keys do too — via psio
ARTPP_PSIO_KEY(double) // order-preserving codec, one macro
artpp::map<double, std::string> m;
m.insert(-3.5, "a"); // IEEE sign-transform: byte
m.insert( 0.0, "b"); // order becomes numeric
m.insert( 2.25, "c"); // order — negatives and all
for (const auto& [k, v] : m) // → -3.5, 0.0, 2.25
log(k, v);
// reflected structs, optionals, variants key the same way
File-backed, 4-byte branches
artpp::line_pool pool("mystore"); // a store directory
using A = artpp::pool_alloc<uint64_t>;
artpp::map<std::string_view, uint64_t,
artpp::mode::none, A> t{A{&pool}, artpp::attach};
t.insert("key", 42);
t.checkpoint(); // what the next open sees
// branches cost 4 bytes; reopening is O(1):
// handles are offsets, the bytes are the tree
Pick the structure per workload
// dictionary-shaped keys? pack the tails:
artpp::map<std::string_view, uint64_t,
artpp::mode::buckets> dict;
// measured in the README's bucket-mode table
Get started in one minute
Header-only. Copy include/artpp, or:
# CMake ≥ 3.20
include(FetchContent)
FetchContent_Declare(artpp GIT_REPOSITORY https://github.com/gofractally/libartpp.git
GIT_TAG main)
FetchContent_MakeAvailable(artpp)
target_link_libraries(your_target PRIVATE artpp::artpp)
# or hack on it directly
git clone https://github.com/gofractally/libartpp && cd libartpp
cmake -B build && cmake --build build -j && ctest --test-dir build
cmake -B build -DARTPP_BENCHMARKS=ON # the compare suite from this page
Requirements: a C++20 compiler, a 64-bit
little-endian target (ARM64/x86-64; NEON and SSE2 paths included), GCC or Clang. Nothing else
(the optional psio key adapter needs C++23 and Boost headers).
MIT licensed.
Full API reference and contracts:
the README.