I have about a million ArrayVec<u8; 1024> stored in the leaves of b-tree. I also have a cursor for traversing this tree. When the cursor traverses the tree it maintains a stack for ancestors of current leaf and a summary of attributes related to tree content.
When performance testing it takes about 16ms to visit all leaves using the Cursor.
To my surprise if I add one more feature... (calling ArrayVec.as_slice() for each visited leaf the performance balloons to 40ms. Is that expected?
It seems to be a one time cost... if I call
as_slice three times for each leave it still takes about 40ms. Also if I replace ArrayVec with normal Vec I see similar behavior.
My question: Why does
as_slice have this cost? It seems out of proportion to the other work that I'm doing to traverse the tree.