News for hackers. Stuff that matters.
Re:Fewer mallocs in curl by blibble on Sunday April 23, 2017 @02:20PM (#14179512)
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)

Re:Fewer mallocs in curl by dxhdr on Sunday April 23, 2017 @04:28PM (#14180295)
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.

Re:Fewer mallocs in curl by vvanders on Sunday April 23, 2017 @04:36PM (#14180326)
Yup, 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.

Re:Fewer mallocs in curl by nostrebored on Sunday April 23, 2017 @03:48PM (#14180081)
you 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.