4 ms·
A structure allocated in one chunk has cache locality and will be significantly faster to access than dereferencing multiple pointers. The allocation itself is
by dxhdr 9y ago
A structure allocated in one chunk has cache locality and will be significantly faster to access than dereferencing multiple pointers.
The allocation itself is not the bottleneck, it's the poor choice of data structure.
- vvanders 9y agoYup, malloc/free isn't usually algorithmically expensive but the cache misses tend to be the brutal part. You'll spend 15 cycles doing work on 600 cycles of cache fetching. Plus you've just evicted some cache for your local scope.