Skip to content

Commit f4cd213

Browse files
committed
CPP_MAPS.md: summary, integer and string key tables with the best compact string, setup last; units spelled out in both comparisons
1 parent fc74a0d commit f4cd213

2 files changed

Lines changed: 163 additions & 164 deletions

File tree

‎bbtree/bench/COMPARISON.md‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ Both ran the same benchmark cells with the same inputs on one machine; see Setup
1313

1414
## Integer keys
1515

16-
The unsync map with `u64` keys and values, ns an operation (iterate: an
17-
entry). The cells are the bench's `ci` suite, its core set at 1k, 1M and
18-
10M entries, named for running in continuous integration. Bold marks
19-
the fastest map of each row. The two right columns compare different
20-
maps: Rust's `BTreeMap` is a B-tree, `std::map` a red-black tree.
16+
The unsync map with `u64` keys and values, nanoseconds per operation
17+
(iterate: per entry); smaller is better. The cells are the bench's `ci`
18+
suite, its core set at 1k, 1M and 10M entries, named for running in
19+
continuous integration. Bold marks the fastest map of each row. The two
20+
right columns compare different maps: Rust's `BTreeMap` is a B-tree,
21+
`std::map` a red-black tree.
2122

2223
| cell | bbtree++ | bbtree (Rust) | Rust `BTreeMap` | C++ `std::map` |
2324
|---|--:|--:|--:|--:|
@@ -52,7 +53,8 @@ optimization round changed" has their current figures.
5253

5354
## String keys
5455

55-
The unsync map, ns an operation (iterate, many maps: an entry). bbtree++
56+
The unsync map, nanoseconds per operation (iterate and many maps: per
57+
entry); smaller is better. bbtree++
5658
runs each string cell with the compact string that is fastest on it,
5759
named in the row: `compact_string` (16 bytes, a 4-byte size, up to 12
5860
bytes in place, the default), `compact_string<2>` (16 bytes, a 2-byte
@@ -132,8 +134,8 @@ Bold marks the smaller figure of each row.
132134
|---|--:|--:|
133135
| 1 thread: insert, ns | **253** | 254 |
134136
| 1 thread: get, ns | **224** | 233 |
135-
| 1 thread: scan, ns an entry | 28.5 (23.0 with the scan's visit inlined) | **19.1** |
136-
| nodes + heap, bytes an entry | 110.6 | **103.6** |
137+
| 1 thread: scan, ns per entry | 28.5 (23.0 with the scan's visit inlined) | **19.1** |
138+
| nodes + heap, bytes per entry | 110.6 | **103.6** |
137139
| churn, heap bytes a live record byte (round 4) | 1.74 | **1.52** |
138140
| 8 threads: insert, ns wall | **67** | 75 |
139141
| 8 threads: get, ns wall | **36** | 39 |
@@ -165,7 +167,7 @@ and churn rows.
165167
| change | effect |
166168
|---|---|
167169
| huge pages in the bench, as the Rust bench's mimalloc has (PORTING.md, [bench dependencies](../../PORTING.md#p12-bench-dependencies-include-mimalloc), [the allocator](../../PORTING.md#p17-the-benchs-allocator-mimalloc-332-behind-operator-new)) | iteration 2× faster: most of the first measurement's gap |
168-
| `for_each`, a depth-first walk with no cursor ([iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)) | 1M u64 walk 0.94 → 0.56 ns an entry, 1k 0.69 → 0.25, 1M maps of 4: 18 → 8 |
170+
| `for_each`, a depth-first walk with no cursor ([iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)) | 1M u64 walk 0.94 → 0.56 ns per entry, 1k 0.69 → 0.25, 1M maps of 4: 18 → 8 |
169171
| one move per shifted object, not two through a temporary ([moves](../../PORTING.md#p6-moves-relocate-only-trivially-relocatable-types-as-bytes)) | 1M `std::string` inserts 252 → 221 ns |
170172
| bulk builds: sorted ranges build in place; a leaf's run appends without the prefix shrink | 1M u64 bulk build 8.1 → 7.0 ns in the bench, 13.2 → 9.6 on a probe |
171173
| shared map appends check the last leaf before latching it, as the Rust crate does (a porting omission) | 8-thread inserts 110 → 45 ns; the store's 143 → 67 |
@@ -184,7 +186,7 @@ four entries a round, and a checksum that folds, as the Rust bench's does
184186
| u64_u64_bulk_build_1M | **5.41** | 5.51 |
185187
| str-json_struct32_iterate_1Mx4, `std::string` keys † | 6.83 | **5.67** |
186188
| str-json_struct32_iterate_100kx32, `std::string` keys | **9.32** | 11.7 |
187-
| store scan, 1M, ns an entry | 23.0 | **20.3** |
189+
| store scan, 1M, ns per entry | 23.0 | **20.3** |
188190

189191
† Across this session's windows 4.6-6.8 ns for bbtree++ and 4.9-5.7 for
190192
the Rust bench; a rerun right after, with no compaction stall in the
@@ -215,9 +217,9 @@ bbtree++'s took 7.2-9.0.
215217
own. Four entries a round in a root leaf ([iteration](../../PORTING.md#p16-for_each-beside-iterators-for-rusts-folds)): `compact_string` keys
216218
0.64-0.71× the Rust crate's `String`, `std::string` keys 1.0-1.2×.
217219
- **The store's scan (1.5× → 1.13×):** the scan's visit and the record's
218-
`value()` were calls, a third more instructions an entry, so fewer
220+
`value()` were calls, a third more instructions per entry, so fewer
219221
entries' record misses overlapped ([store scans](../../PORTING.md#p31-a-store-scans-visit-inlines-into-the-maps-loop)). What is left is bbtree++'s 7
220-
more heap bytes an entry (87 against 80; [heads' records](../../PORTING.md#p24-a-leafs-head-keys-record-stays-put)). Long values (1.1-1.3×)
222+
more heap bytes per entry (87 against 80; [heads' records](../../PORTING.md#p24-a-leafs-head-keys-record-stays-put)). Long values (1.1-1.3×)
221223
are not looked into.
222224

223225
Everything else is within 10% or faster, mostly from bbtree++'s lookups

0 commit comments

Comments
 (0)