From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: copy.c allocation constant |
Date: | 2018-01-24 20:35:44 |
Message-ID: | 20180124203544.GO17109@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jan 25, 2018 at 09:30:54AM +1300, Thomas Munro wrote:
> On Thu, Jan 25, 2018 at 7:19 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> > On Wed, Jan 24, 2018 at 12:25 PM, Tomas Vondra
> > <tomas(dot)vondra(at)2ndquadrant(dot)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(dot)gmail(dot)com#CAEepm=1bRyd+_W9eW-QmP1RGP03ti48zgd=K11Q6o4edQLgkcg(at)mail(dot)gmail(dot)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.
The BSD memory allocator used to allocate in powers of two, and keep the
header in a separate location. They did this so they could combine two
free, identically-sized memory blocks into a single one that was double
the size. I have no idea how it works now.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2018-01-24 20:36:16 | Re: WIP Patch: Precalculate stable functions, infrastructure v1 |
Previous Message | Thomas Munro | 2018-01-24 20:30:54 | Re: copy.c allocation constant |