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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid statically allocating formatting.c's format string caches.
Date: 2018-10-16 17:11:21
Message-ID: E1gCSsL-0000wT-LX@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-10-16 17:24:48 pgsql: Fix mis-backpatch of c015ccb306ec81bca3023818c9cf0113cae25be1.
Previous Message Andres Freund 2018-10-16 16:45:31 pgsql: Correct constness of system attributes in heap.c & prerequisites