Re: PATCH: two slab-like memory allocators
От | Petr Jelinek |
---|---|
Тема | Re: PATCH: two slab-like memory allocators |
Дата | |
Msg-id | 2a7c720f-9934-8306-7247-ba5271511e56@2ndquadrant.com обсуждение исходный текст |
Ответ на | Re: PATCH: two slab-like memory allocators (Tomas Vondra <tomas.vondra@2ndquadrant.com>) |
Список | pgsql-hackers |
On 05/10/16 03:11, Tomas Vondra wrote: > On 10/04/2016 09:44 PM, John Gorman wrote: >> >> Remind me again why we cannot realloc in place for sizes >> smaller than chunkSize? GenSlab is happy to allocate smaller >> sizes and put them into the fixed size chunks. >> >> Maybe SlabAlloc can be happy with sizes up to chunkSize. >> >> if (size <= set->chunkSize) >> return MemoryContextAlloc(set->slab, size); >> else >> return MemoryContextAlloc(set->aset, size); >> > > That'd be certainly possible, but it seems a bit strange as the whole > Slab is based on the idea that all chunks have the same size. Moreover, > people usually realloc() to a larger chunk, so it does not really fix > anything in practice. > > In GenSlab, the situation is more complicated. But I don't like the > coupling / moving chunks between contexts, etc. > > If realloc() support is a hard requirement, it immediately rules out > SlabContext() as an independent memory context. Which seems stupid, as > independent Slab contexts are quite useful for reorderbuffer use case. > > For GenSlab the situation is less clear, as there probably are ways to > make it work, but I'd vote to keep it simple for now, and simply do > elog(ERROR) in the realloc() methods - both for Slab and GenSlab. The > current use case (reorderbuffer) does not need that, and it seems like a > can of worms to me. > Hmm, so this in practice means that the caller still has to know the details of what chunks go where. I would prefer if the realloc just failed always and "don't do realloc on GenSlab" would be part of spec of hat context, the randomness that you described originally is the main problem IMHO. Maybe you could add new "constructor" function for Aset that would create Aset which can't realloc for use inside the GenSlab? Alternative would be of course having the individual API calls behind Aset and Slab exported and used by GenSlab directly instead of using child contexts. Then all the calls would go to GenSlab which could decide what to do (and move the chunks between the allocators). But honestly given the usecases for GenSlab, I would at the moment prefer just to have predictable error as it can be done more cleanly and nobody needs the functionality so far, it can be revisited once we actually do need it. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-hackers по дате отправления: