3 ms·
I can't read OCaml code so well, but it seems that the list you are allocating completely fits within the nursery. If it was larger than the nursery, it would h
by bjourne 9y ago
I can't read OCaml code so well, but it seems that the list you are allocating completely fits within the nursery. If it was larger than the nursery, it would have to be promoted to a higher generation which I'm sure would slow down the linked list code a lot. Promoting a dynamic array isn't nearly as expensive because it is just one big object, not thousands of list nodes.
- rbehrends 9y agoYes, that's exactly the point I was getting at. We're dealing with temporary values for which you'd use an arena/pool allocator in C/C++. The nursery is essentially an arena allocator that works transparently for temporary values. My point is also not that it's always better, but that it's not safe to make blanket assumptions about GC overhead. And if you're dealing with long-lived data of varying sizes, then the manual allocation story isn't that great, either.