Re:Rust Is Hard, Or: The Misery of Mainstream Programming
by rapsey on Thursday June 02, 2022 @10:42PM
(#31603630)
However the constant checking if something is on the stack or heap is a big performance problem for smallvec. It results in terrible cpu branch prediction.
[ Parent
| on HN ]
Re:Rust Is Hard, Or: The Misery of Mainstream Programming
by kaba0 on Friday June 03, 2022 @06:44AM
(#31606613)
I don't see how is it bad for branch prediction. Like, if you use the same smallvec object in a loop and do not insert any elements to it (so that it doesn't allocate on the heap) the branch will always turn in the same direction making it easy and cheap to predict. And I would think that in most use-cases your smallvec object will either remain in one state, not changing in-between.