Re:Fast, simple, hard real time allocator for Rust
by sapiogram on Thursday May 02, 2024 @06:53AM
(#40234721)
Note that rustc will not emit this instruction by default, to support older CPUs. Without `target-cpu=haswell` or similar, the operation will be quite slow, but still O(1) of course.
[ Parent
| on HN ]
Re:Fast, simple, hard real time allocator for Rust
by jsheard on Thursday May 02, 2024 @07:20AM
(#40234872)
It's not that bad, all x86 processors have the BSR instruction which can be mapped to LZCNT semantics with just a few extra instructions.
Left to right - modern x86-64, baseline x86-64, baseline i686:
https://rust.godbolt.org/z/nGsM35TEo
Maybe you're thinking of POPCNT, which hurts a lot more if it doesn't compile down to the native instruction: