|
|
|
|
|
by raible
1321 days ago
|
|
FWIW I usefully use a "fake" linked list by adding a .next field to the struct in a compiler-allocated array of structs. On initialization I set the list head to &item[0], and in a trivial loop set the .next field of each entry (except the last) to entry+1. Why bother? Because I can then easily add a few extra structs to the beginning of the (contiguously-allocated) linked-list without having to reallocate the whole thing. Sure, pointer chasing with separately allocated structs is "slow", but I haven't yet measured to see if it's any different when (almost all) items are contiguous. If you would...
- what sort of cache behavior should one expect of this on a modern laptop CPU?
- I haven't seen this approach before, have you? |
|
[1] https://www.prefetchers.info/augury.pdf