stable-vec
stable-vec copied to clipboard
Random notes: performance
I'm currently working on another performance-critical project that uses this crate. I'm inspecting generated assembly code and noted some possible improvements to this crate. Before I forget all of this, here is a random list of notes:
- ~~Using
bitvec[index]
is bad: because that crate uses thestatic TRUE/FALSE
trick to in the[]
operator we have a branch where there shouldn't be one. Useget
instead or something like that~~ - ~~First indexing the bitvec and then the data vec does two bound checks. That's bad. Everywhere where we use
has_element_at
(and it returnstrue
), we should useget_unchecked
or so.~~ - Setting or resetting a bit (done via
&
or|
with a mask) is not optimized well. This should (probably be done) with the BTS and BTR instructions on x86. Have too look into this.
(This issue is rather a reminder to myself...)