-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Towards faster binary search #74547
Comments
Please edit to use permanent link: Lines 1565 to 1570 in 05630b0
|
I've just tried a quaternary search and it's slower than the std one |
Binary search ought to be the most overstudied algorithm in computer science. It's important to keep that in mind when one sees a new revelation about it on Hacker News. If one is interested in experimenting with the different n-ary search algorithms in Rust in a crate, then that sounds like an idea, but it seems out of scope for the standard library. All the more that the quaternary variant, where they report a “25%” speed-up in their tests and data set, is clearly not a “binary search” any more (though for some reason they call it a “quaternary binary search”, which is funny), so it in no way can replace the std's binary search. |
There is also branchless Binary searches that can benefit from SIMD |
Also see #53823 : the problem is not branchless, but how easy the CPU could predict it. |
rust/src/libcore/slice/mod.rs
Lines 1565 to 1570 in 05630b0
Could be improved in the same way as rust has switched it's old hashmap to the state of the art hashbrown.
It seems that there is a new state of the art Binary search in town leading up to 25% performance improvement and binary search is a foundational task.
Therefore it would be promising to investigate whether Rust could have a faster binary search implementation, the candidate being
https://news.ycombinator.com/item?id=23893366
(but maybe there are other new state of the art)
The text was updated successfully, but these errors were encountered: