Hi, On 2019-02-25 17:55:46 -0800, Andres Freund wrote: > Hm, I wonder if that's necessary / whether we can just work around user > visible breakage at a small cost. I think I'm mostly concerned with two > allocations for the very common case of small (1-3 entries) lists. We > could just allocate the first array together with the header, and not > free that if the list grows beyond that point. That'd mean we'd only do > separate allocations once they actually amortize over a number of > allocations.
Btw, if we actually were going to go for always allocating header + data together (and thus incuring the problems you mention upthread), we ought to store the members as a FLEXIBLE_ARRAY_MEMBER together with the list. Probably not worth it, but reducing the number of pointer indirections for "list" accesses would be quite neat. Greetings, Andres Freund