3 ms·
so what, to return from a freelist you alter the head pointer to point to the next item and return it that's what, 2 or 3 instructions? even if you push that u
by blibble 10y ago
so what, to return from a freelist you alter the head pointer to point to the next item and return it
that's what, 2 or 3 instructions? even if you push that upto a few hundred it's still effectively free compared to anything else curl is going to do (e.g. writing to the disk)
- nostrebored 10y agoyou have to handle the case in which you have no remaining items as well, breaking up a chunk log(chunkToBreak/chunkSizeNeeded) times. And in the case that you have no viable chunk to use, you need to call back to the OS.
- dxhdr 10y agoA 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 10y 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.