You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 288dfd0
Browse filesBrowse the repository at this point in the historyBrowse files
† bbtree's runs of this cell ranged from 88 to 129 ns today (93.4 in
74
+
† bbtree++'s runs of this cell ranged from 88 to 129 ns today (93.4 in
76
75
COMPARISON.md; 110 on a rerun of the cell alone, at load 0.8); abseil's
77
76
from 111 to 146. Unsettled: read it as about even.
78
77
79
78
## `compact_string` keys against `std::string` keys
80
79
81
-
`bbtree-unsync-compact` is bbtree's unsync map with `bbtree::compact_string`
80
+
`bbtree-unsync-compact` is bbtree++'s unsync map with `bbtree::compact_string`
82
81
keys (PORTING.md, [compact_string](../../PORTING.md#p29-compact_string-12-bytes-in-place-the-size-in-one-place)): 16 bytes, up to 12 in place, moved as bytes. The
83
82
cell turns its keys into compact strings before it times anything.
84
83
`bbtree-bench cpp --key str-16,str-json --map
85
84
bbtree-unsync,bbtree-unsync-compact,absl-btree,std-btree`, one run each,
86
-
started at load 0.3, with the root-leaf walk (PORTING.md, [iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)). Rust is the Rust
87
-
crate's bbtree with `String` keys, from COMPARISON.md.
85
+
started at load 0.3, with the root-leaf walk (PORTING.md, [iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)). bbtree (Rust),
@@ -112,12 +111,12 @@ crate's bbtree with `String` keys, from COMPARISON.md.
112
111
iterate in 5.6 ns an entry with `std::string` keys and 3.2 with
113
112
`compact_string` keys (COMPARISON.md).
114
113
115
-
† bbtree's columns re-run after the checksum became a fold (PORTING.md, [iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)).
116
-
‡ Not comparable with the other runs: bbtree's maps of 4 take 1.1 GB of
114
+
† bbtree++'s columns re-run after the checksum became a fold (PORTING.md, [iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)).
115
+
‡ Not comparable with the other runs: bbtree++'s maps of 4 take 1.1 GB of
117
116
fresh pages, and with the machine's memory mostly page cache, getting huge
118
117
pages stalled the kernel in compaction (29 stalls in one run of the cell,
119
118
none in abseil's, which takes a third as much). The same cell took 78 ns
120
-
with `std::string` keys earlier in the session; the two bbtree columns of
119
+
with `std::string` keys earlier in the session; the two bbtree++ columns of
121
120
this run stalled alike.
122
121
123
122
-**Writes:** an entry of a string → `u64` leaf shrinks from 49 bytes to
@@ -184,14 +183,14 @@ iterate in 5.6 ns an entry with `std::string` keys and 3.2 with
184
183
The heap bytes a map holds after its build, divided by its entries:
185
184
`bbtree-bench-memory cpp`, which counts the bytes mimalloc hands out
186
185
(`mi_usable_size`) and frees, one run each. The counts don't depend on
187
-
the machine's load. bbtree's string rows have the compact string that
186
+
the machine's load. bbtree++'s string rows have the compact string that
188
187
suits the keys (see above): `compact_string_24` (`bbtree-unsync-compact-24`,
189
188
24 bytes, up to 20 in place) for `str-16`, whose keys it mostly holds in
190
189
place, and the default `compact_string` (`bbtree-unsync-compact`, 16 bytes,
191
190
a 4-byte size, up to 12 in place) for JSON keys. The other maps have
@@ -209,7 +208,7 @@ a 4-byte size, up to 12 in place) for JSON keys. The other maps have
209
208
node is 32 bytes of links and colour beside the entry's 16, mimalloc's
210
209
48-byte size class. With `std::string` keys a node is 72 bytes, in the
211
210
80-byte class, plus a heap buffer for each key past 15 bytes.
212
-
-**bbtree's**`u64` entry is its 16 bytes and a 2-byte inline key: 18.5
211
+
-**bbtree++'s**`u64` entry is its 16 bytes and a 2-byte inline key: 18.5
213
212
bytes in the full leaves of a bulk build, 23.6 after ascending inserts,
214
213
26.9 after random ones, which leave leaves about 70% full. abseil's
215
214
nodes keep no inline keys and are 1-6 bytes an entry smaller.
@@ -220,15 +219,15 @@ a 4-byte size, up to 12 in place) for JSON keys. The other maps have
220
219
48.8 against 55.2 in a bulk build, but 68.3 against 65.5 after
221
220
sequential inserts. On JSON keys it takes 61.5 against 51.0. The
222
221
2-byte-size variant is 1-2.4 bytes smaller than `compact_string` on
223
-
every cell. With `std::string` keys bbtree takes
222
+
every cell. With `std::string` keys bbtree++ takes
224
223
76.9 bytes an entry on 1M JSON keys (0.93× std::map) and 72-106 on
225
224
`str-16` at 1k.
226
225
-**The Rust crate** takes the same bytes on every `u64` cell; with its
227
226
24-byte `String` keys it takes 68.4 on 1M JSON keys.
228
227
229
228
## Against abseil's B-tree
230
229
231
-
-**bbtree is faster:**
230
+
-**bbtree++ is faster:**
232
231
- lookups: 1.5× on u64, 2-3× on 16-byte strings;
233
232
- string inserts and upserts: 1.6×;
234
233
- sequential inserts: 1.5-2×;
@@ -240,24 +239,24 @@ a 4-byte size, up to 12 in place) for JSON keys. The other maps have
240
239
- many 4-entry maps: 1.6× to build, 2.4× to iterate; to iterate 1.6×
241
240
since the walk reads root leaves four entries a round, which came after
242
241
these tables
243
-
(bbtree 5.6 ns an entry, `compact_string` keys 3.2; COMPARISON.md).
242
+
(bbtree++ 5.6 ns an entry, `compact_string` keys 3.2; COMPARISON.md).
244
243
-**About even:** removes, bulk builds, lookups in many small maps.
245
-
-**At 1M and 10M:** bbtree misses 1.75-1.85× faster on u64 and 2.5× on
244
+
-**At 1M and 10M:** bbtree++ misses 1.75-1.85× faster on u64 and 2.5× on
246
245
JSON strings, hits 1.4-1.6× faster at 10M u64 and on strings, inserts
247
246
JSON strings 1.5× and sequential u64 3.4× faster, and iterates 2.2×
248
247
faster. abseil pops the first entry 2.1× faster and scans `range64`
249
248
1.16× faster; random u64 inserts, removes, upserts and bulk builds are
250
249
within 11%.
251
250
252
-
The Rust original has the 1k insert gap too: COMPARISON.md has Rust's
253
-
bbtree at 36.0 ns on 1k random u64 inserts against `BTreeMap`'s 17.5, so
254
-
that gap comes from the design, not the port. Of the many-map gaps,
251
+
The Rust original has the 1k insert gap too: COMPARISON.md has
252
+
bbtree (Rust) at 36.0 ns on 1k random u64 inserts against `BTreeMap`'s 17.5, so
253
+
that gap comes from the design, not bbtree++. Of the many-map gaps,
255
254
iteration was profiled: the walk read a leaf's entries with one load,
256
255
whose steps the prefetcher didn't follow (since fixed; PORTING.md, [iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)). Building them
257
256
pays a full 1 KiB root page a map, where abseil sizes its root leaf to its
258
257
entries (FUTURE_WORK.md). No Rust `BTreeMap` figures for the many-map
259
258
cells are at hand.
260
259
261
260
`std::unordered_map` beats every ordered map on lookups, random inserts
262
-
and upserts, as expected; not on sequential inserts, which bbtree appends
261
+
and upserts, as expected; not on sequential inserts, which bbtree++ appends
0 commit comments