Generator

Search cost against fanout, n = 4,194,304

Rendered here at the parameters it defaults to, with every essay that calls it — which is the same list as the blast radius of changing it.
Search cost against fanout, n = 4,194,304A B-tree over 4,194,304 keys at 5 block sizes. The outline is the tree's height — the number of nodes on a root-to-leaf path — and the filled bar is the transfers a search actually paid, averaged over 200 random queries. The two differ because the top levels of the tree are few enough blocks to stay in memory: at B = 1024 the height is 3 and the measured cost is 1.01. Binary search over the same keys costs 20 transfers, and its cost does not depend on B at all.levels on the path (outline) · transfers actually paid (filled)B = 411 levels · 6.99 transfers · 16,384 blocks residentB = 166 levels · 3.23 transfers · 4,096 blocks residentB = 644 levels · 1.99 transfers · 1,024 blocks residentB = 2563 levels · 1.30 transfers · 256 blocks residentB = 10243 levels · 1.01 transfers · 64 blocks residentbinary search over the same 4,194,304 keys: 20 transfersB = 1024, M = 65,536 (M/B = 64)20× between binary search and the widest tree

Search cost against fanout, n = 4,194,304

A B-tree over 4,194,304 keys at 5 block sizes. The outline is the tree's height — the number of nodes on a root-to-leaf path — and the filled bar is the transfers a search actually paid, averaged over 200 random queries. The two differ because the top levels of the tree are few enough blocks to stay in memory: at B = 1024 the height is 3 and the measured cost is 1.01. Binary search over the same keys costs 20 transfers, and its cost does not depend on B at all.

Drawn at 700 × 380, wide on the page. Everything above is what btree-shape returns with no arguments; the caption is the generator's own, computed from the numbers in the drawing rather than written beside it.

5 essays call btree-shape. The drawing above is what it returns with no arguments at all; every call below passes it something, because a placement that passes nothing draws whichever member of the family the generator happens to default to rather than the one its essay argues about — which is what optcheck and figfill exist to catch.

Where it is called

Changing this generator changes every one of these figures.

1100ε — the exponent the fanout is B toelements written per key33445679ε = 1 — the B-tree ·fanout 256 · 3transfers a queryε = 0.5 · fanout 16 · 5a querythe number above eachpoint is what a querycostsB = 256, M = 16,384 (M/B = 64)131,072 random keys When it does not fit

One dial between two structures

levels on the path (outline) · transfers actually paid (filled)B = 411 levels · 6.99 transfers · 16,384 blocks residentB = 166 levels · 3.23 transfers · 4,096 blocks residentB = 644 levels · 1.99 transfers · 1,024 blocks residentB = 2563 levels · 1.30 transfers · 256 blocks residentB = 10243 levels · 1.01 transfers · 64 blocks residentbinary search over the same 4,194,304 keys: 20 transfersB = 1024, M = 65,536 (M/B = 64)20× between binary search and the widest tree Structures

A tree with nodes the size of a block

0%25%50%75%100%ln 2mean leaf fillrandom, even splits2,906 leavesrandom, rightmost-split rule2,949 leavesascending, even splits3,971 leavesascending, rightmost-split rule2,048 leavesdescending, even splits4,095 leavesdescending, rightmost-split rule4,095 leavesbulk-loaded from sorted keys2,048 leaves131,072 keys, leaves of 64each bar names its rule When it does not fit

The keys that arrive late

50%60%70%80%90%100%0%1%2%5%10%25%50%share of keys arriving latemean leaf filleven splitsrightmost-split rulesibling first, two into threeln 2131,072 keys, leaves of 64late keys arrive at a random later point When it does not fit

The sibling a full leaf asks first

6080100how far a full leaf looks for room, in siblingsmean leaf fill, per cent12481664randomascendingdescendingascending, 1% late131,072 keys · leaves of 64 · fan-out 64a reach of 1 is the adjacent-sibling rule When it does not fit

A key passed along the row

The library, page 1 of 5 — where btree-shape sits