Comment

Comment by listeria

This reminds me of two excellent articles[1][2] by Paul Khuong, in which he talks about using size-specialized binary search for power-of-two sized arrays (special-casing the first iteration for other sizes).

He uses conditional moves and defines the number of iterations in advance to ellide the often mispredicted branch, and in the second article goes on to fix cache aliasing issues for large vectors using ternary search.

[1]: https://pvk.ca/Blog/2012/07/03/binary-search-star-eliminates...

[2]: https://pvk.ca/Blog/2012/07/30/binary-search-is-a-pathologic...

parent listeria 6 months ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton