Re: copy.c allocation constant
От | Andres Freund |
---|---|
Тема | Re: copy.c allocation constant |
Дата | |
Msg-id | 20180124184319.4k3qwpn4tu5fnhnh@alap3.anarazel.de обсуждение исходный текст |
Ответ на | Re: copy.c allocation constant (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: copy.c allocation constant
|
Список | pgsql-hackers |
On 2018-01-24 13:19:19 -0500, Robert Haas wrote: > On Wed, Jan 24, 2018 at 12:25 PM, Tomas Vondra > <tomas.vondra@2ndquadrant.com> wrote: > > At the glibc level ... I'm not so sure. AFAIK glibc uses an allocator > > with similar ideas (freelists, ...) so hopefully it's fine too. > > > > And then there are the systems without glibc, or with other libc > > implementations. No idea about those. > > My guess is that a fairly common pattern for larger chunks will be to > round the size up to a multiple of 4kB, the usual memory page size. Indeed. Don't think RAW_BUF_SIZE is quite big enough for that on most platforms though. From man mallopt: Balancing these factors leads to a default setting of 128*1024 for the M_MMAP_THRESHOLD parameter. Additionally, even when malloc() chooses to use mmap() to back an allocation, it'll still needs a header to know the size of the allocation and such. So exactly using a size of a multiple of 4KB will still leave you with wasted space. Due to the latter I can't see it mattering whether or not we add +1 to a power-of-two size. There's malloc_usable_size() returning the actual size of an allocation. It'd probably be worthwhile to use that in a few of our own allocator routines. If not available on a platform we can just have a stub that returns the requested size... Greetings, Andres Freund
В списке pgsql-hackers по дате отправления: