Re:In Defense of Linked Lists
by robotresearcher on Friday November 04, 2022 @08:43PM
(#33476336)
That's absolutely right, but it's not just large objects. Any situation where you follow links rarely compared to your other memory accesses then the cache performance of links becomes negligible and the benefit of simplicity and O(1) operations can shine. Vectors for scrubbing through things without changing their structure, lists and trees the opposite.
Scrubbing through things quickly is empirically more common, hence the standard advice to use vectors by default.
Re:In Defense of Linked Lists
by scaramanga on Friday November 04, 2022 @09:33PM
(#33476747)
Or how about an object that can't easily be relocated like, you know, a stack for a kernel thread which also contains the task struct and needs to be moved around between different scheduler queues.
But yeah, I understand they took the task struct out of the kernel stack now.
Edit: difficult being an understatement, you'd need to solve the halting problem to be able to rewrite any self-referential pointers to stack objects wherever they may be.
If you combine intrusive linking with a pool allocator, you can have decent locality too.