pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid statically allocating formatting.c's format string caches.
Date: Tue, 16 Oct 2018 17:11:21 +0000
Message-ID: <E1gCSsL-0000wT-LX@gemulon.postgresql.org> (raw)

Avoid statically allocating formatting.c's format string caches.

This eliminates circa 120KB of static data from Postgres' memory
footprint.  In some usage patterns that space will get allocated
anyway, but in many processes it never will be allocated.

We can improve matters further by allocating only as many cache
entries as we actually use, rather than allocating the whole array
on first use.  However, to avoid wasting lots of space due to
palloc's habit of rounding requests up to power-of-2 sizes, tweak
the maximum cacheable format string length to make the struct sizes
be powers of 2 or just less.  The sizes I chose make the maximums
a little bit less than they were before, but I doubt it matters much.

While at it, rearrange struct FormatNode to avoid wasting quite so
much padding space.  This change actually halves the size of that
struct on 64-bit machines.

Discussion: https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fd85e9f78d44f0f36776e644380ada077451c992

Modified Files
--------------
src/backend/utils/adt/formatting.c | 94 +++++++++++++++++++++++---------------
1 file changed, 56 insertions(+), 38 deletions(-)



Message-ID: <E1gCSsL-0000wT-LX@gemulon.postgresql.org>
Permalink:  ../E1gCSsL-0000wT-LX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gCSsL-0000wT-LX@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid statically allocating formatting.c's format string caches.
  In-Reply-To: <E1gCSsL-0000wT-LX@gemulon.postgresql.org>
  References: <E1gCSsL-0000wT-LX@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox