• Tom Lane's avatar
    Avoid statically allocating formatting.c's format string caches. · fd85e9f7
    Tom Lane authored
    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
    fd85e9f7
formatting.c 142 KB