I am aware about the concepts of data type or structure alignment, packing, padding issues etc. I have implemented a single linked list where each node occupies approximately 250 bytes i.e. around 4 times the size of cache line of 64 bytes. My machine is a Intel 64 bit architecture.
Now a single linked list is essentially a pointer chasing data structure and thus suffers from high number of cache misses. In order to reduce the cache misses, I aligned each data structure node using *posix_memalign* function to cache lined boundary of 64 bytes. Now all linked list nodes are cache aligned.
After doing this, I find that memory consumption of linked list has increased considerably and also the performance has actually deteriorated. Can anyone explain what could be possibly going wrong ?
I don’t know what malloc you use but this is from tcmalloc