~/talk

Optimizing Binary Search

Talkat CppCon 2022 · 2022-09-11..09-16· [rust]
links:none on file
slides:none on file

Claims concrete speedups over std::lower_bound with measurable tradeoffs: up to ~15× faster on small arrays and ~7× on large ones. Achieves this by replacing textbook binary search with a preprocessed layout (Eytzinger-style permutation then a B+tree-like layout whose nodes hold 16 32-bit keys to fit a 64‑byte cache line), using branchless conditional-move logic, targeted prefetching, and AVX2 vector compares producing masks so each node search is few cache-line reads and wide SIMD comparisons rather than many unpredictable branches.

AI-written summary · about

  1. 0:00Introduction
  2. 1:37Agenda
  3. 2:47Formalization
  4. 3:53Comparisons
  5. 6:36Average Time
  6. 8:31Pipeline
  7. 9:11Hazards
  8. 12:29Loop Condition
  9. 17:57Cache Efficiency
  10. 18:47Cache Lines
  11. 19:58Memory Optimization
  12. 21:15Ancestor Number System
  13. 22:44Binary Tree
  14. 24:41Example
  15. 27:57Performance
  16. 31:07Risk
  17. 33:17Node Size
  18. 38:02Vector procedure
  19. 39:24Bitrees
  20. 40:22Two fundamental problems
  21. 41:01Btrees
  22. 42:16Performance improvements
  23. 44:52Adaptive tree growth
  24. 46:02Layer modifications
  25. 47:04Other data types
  26. 48:51B3 inspired approach
  27. 49:35Results
  28. 50:44Question
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.