WordVec 0.2.0 released, up to 38% faster iteration than SmallVec

Sorry if the title reads like a clickbait — it is taken from the index_many::linear_singleton benchmark. Other *_many_* benchmarks involving small vectors also observed various improvements from 12% to 37%. Notably, other length-setting benches are mostly statistically slower or equivalent to SmallVec. See the repo readme for more detailed analysis.

1 Like

if you're optimizing for small vectors, maybe it would be better to have the length lsb be 0 for a small inline vector and 1 for a heap vector, that way small inline vectors may require less operations for small inline vectors since you don't have to | 1 all the time.

1 Like

For N = 1, the compiled code for as_slice is identical to

if marker == 1 { &[] }
else if marker == 3 { slice::from_ref(small) }
else { slice::from_raw_parts(ptr+16, *ptr) }

so it is probably not much different. but for N > 1 it's a good idea indeed.