Re: copy.c allocation constant - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: copy.c allocation constant
Date
Msg-id CAEepm=0c1=w-EVa928wHuPH+JDkL3hmPoSNz8vAq6OUYvMOX2Q@mail.gmail.com
Whole thread Raw
In response to Re: copy.c allocation constant  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: copy.c allocation constant
List pgsql-hackers
On Thu, Jan 25, 2018 at 7:19 AM, Robert Haas <robertmhaas@gmail.com> 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.

See also this discussion:


https://www.postgresql.org/message-id/flat/CAEepm%3D1bRyd%2B_W9eW-QmP1RGP03ti48zgd%3DK11Q6o4edQLgkcg%40mail.gmail.com#CAEepm=1bRyd+_W9eW-QmP1RGP03ti48zgd=K11Q6o4edQLgkcg@mail.gmail.com

TL;DR glibc doesn't actually round up like that below 128kB, but many
others including FreeBSD, macOS etc round up to various page sizes or
size classes including 8kB (!), 512 bytes.  I find this a bit
frustrating because it means that the most popular libc implementation
doesn't have the problem so this kind of thing probably isn't a high
priority, but probably on most other Unices (and I have no clue for
Windows) including my current favourite we waste a bunch of memory.

-- 
Thomas Munro
http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: [HACKERS] Parallel tuplesort (for parallel B-Tree index creation)
Next
From: Bruce Momjian
Date:
Subject: Re: copy.c allocation constant