Skip to content

price index as a two-level B+ tree on flat arrays - #2

Merged
ilyapt merged 7 commits into
mainfrom
index-as-bplus
Oct 23, 2026
Merged

ilyapt merged 7 commits into
mainfrom
index-as-bplus

Conversation

@ilyapt

@ilyapt ilyapt commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

go test -run '^$' -bench . -benchmem -count 3 ./book, Apple M3 Pro, Go 1.26, medians of 3 runs, ns/op, 0 allocs/op everywhere.

Blocked side (blocks of 128 entries behind a chain of block keys) vs a flat sorted slice of the same entries with the same gallop search. Bid side, best price at the end.

scenario levels blocks flat
lookup at a uniform random price 100 27.7 26.9
lookup at a uniform random price 1 000 44.6 43.1
lookup at a uniform random price 10 000 67.2 64.9
lookup at a uniform random price 50 000 85.2 96.0
lookup within the 10 best 100 15.4 15.2
lookup within the 10 best 1 000 15.3 15.2
lookup within the 10 best 10 000 15.3 15.2
lookup within the 10 best 50 000 15.4 15.2
remove + insert within the 10 best 100 40.8 39.4
remove + insert within the 10 best 1 000 40.9 39.9
remove + insert within the 10 best 10 000 40.9 39.8
remove + insert within the 10 best 50 000 40.8 40.8
remove + insert at a random depth 100 84.0 82.4
remove + insert at a random depth 1 000 116 264
remove + insert at a random depth 10 000 166 1 997
remove + insert at a random depth 50 000 210 12 395
best price any 1.1 0.5
walk the 10 best levels with a cursor 1 000 8.2 8.0
walk the 10 best levels into a buffer 1 000 9.4 8.0
walk the 50 best levels with a cursor 1 000 34.3 31.3
walk the 50 best levels into a buffer 1 000 34.7 31.3

@ilyapt
ilyapt marked this pull request as ready for review October 23, 2026 15:14
@ilyapt
ilyapt merged commit 1fa0c03 into main Oct 23, 2026
3 checks passed
@ilyapt
ilyapt deleted the index-as-bplus branch October 23, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant