Under which circumstances are the elements of a linked list laid next to each-other in memory?

Hécate hecate at glitchbra.in
Wed Nov 13 12:39:46 UTC 2024


Hi everyone,

I was asked at work today why I went for Vector instead plain old List 
in order to store an API result that is quite small.

While writing my reasons (pointer indirection, conversion to Aeson's 
internal representation of a JSON array using Vector), I remember that I 
heard that in some cases, GHC would be able to lay down in memory the 
elements of a linked list next to each other. I don't think this gets 
rid of the pointer-chasing, but I'm interested to know more about the 
circumstances in which linked lists are optimised.

Does anyone know if there is a wiki page or something that I could read 
on the topic of linked list optimisation **other than fusion**?

Cheers,
Hécate

-- 
Hécate ✨
🐦: @TechnoEmpress
IRC: Hecate
WWW: https://glitchbra.in
RUN: BSD



More information about the ghc-devs mailing list