-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<algorithm>: algorithms should use TMP to provide optimized implementation for vector<bool> iterators #625
Comments
So I was playing around a bit with this. As far as I understand one would need to specialize First, one would have to check whether Second offsets. As far as I understand one could use unaligned
Does that sound like an improvement? |
This is something that might not be a pure win because of the extra logic needed to handle partial bytes at the beginning and end, as you observed, but there's a potential improvement (8x or more) in the middle, so I think it's worth doing. Previously, optimizing |
Probably well-known, but Howard Hinnant wrote a blog about optimized algorithms for |
In our code base me made huge performance improvements by not doing algorithms on vector but doing them on the underlying implementation instead. For example instead of doing
we changed it to
It would be great if we could get decent performance wouldn't needing to rely on the underlying implementation. |
I have implementations for most of the algorithms, waiting for the first to be reviewed again. That said using algorithms in the implementation is super risky if one does not go over full blocks |
MS's STL already uses metaprogramming to help the optimizer produce
optimized code. As an example,
std::fill
delegates tostd::memset
if safe, which has the advantage of guaranteed good performance in
Debug
mode, as well as not having to rely on the optimizer to salvagereasonable ASM out of the actual code.
I would like optimizations like this to also happen when calling various
algorithms on
std::vector<bool>
, which currently does not happen.As an example, this code
should end up calling
memset
, rather than doing whatever this is.Other algorithms that could be optimized:
std::copy
std::count
std::find
std::equal
This would also improve the performance of
std::vector<bool>
's member functions, as it internally uses std algorithms.The text was updated successfully, but these errors were encountered: