3 ms·
This isn't free either because the free list is scattered around in memory and all that pointer chasing is bad for caches.
by exDM69 10y ago
This isn't free either because the free list is scattered around in memory and all that pointer chasing is bad for caches.
- dbaupp 10y agoI'm curious if any allocators with size classes/buckets actually do much pointer chasing. One can theoretically have a free-list for each class, so at most one pointer needs to be dereferenced: work out the size class, load the front of the appropriate list, read its tail pointer and store that as the new front of the list.
- Someone 10y agoIt isn't free, but all that pointer chasing is one step for each allow and one for each free. There is no need to look for a 'best' block on alloc, nor is there a need to search for a best place to insert a block on free. Moreover, the cache hit you take for an alloc likely would have happened anyways because, presumably, the program that made the allocation wants to write to the allocated memory (in theory, that doesn't imply the CPU has to _read_ the memory, but are there allocators that are that smart?) For frees, the memory may, but need not be, already be in the cache when free is called.