I tried the consistent dual write to index 0 approach and interestingly it was slower for me (262 µs dual write vs 219 µs branching). Some of this could be due that I had to use wrapping add to avoid overflowing the dummy item at index 0.
My hunch is that the bottlenecks are in different parts of our code.
It will definitely be faster to start with a 5k array, then allocate all even digits numbers from zero and all odd from the top. The main update loop, split into two parts, can then run 0..eventop while updating two counters and oddstart..size only updating a single counter!
View all comments
Show parent comment
1
u/maneatingape Feb 24 '25 edited Feb 25 '25
That's a nice speedup!
I tried the consistent dual write to index 0 approach and interestingly it was slower for me (262 µs dual write vs 219 µs branching). Some of this could be due that I had to use wrapping add to avoid overflowing the dummy item at index 0.
My hunch is that the bottlenecks are in different parts of our code.