• Tom Lane's avatar
    Further reduce memory footprint of CLOBBER_CACHE_ALWAYS testing. · d3f48dfa
    Tom Lane authored
    Some buildfarm members using CLOBBER_CACHE_ALWAYS have been having OOM
    problems of late.  Commit 2455ab48 addressed this problem by recovering
    space transiently used within RelationBuildPartitionDesc, but it turns
    out that leaves quite a lot on the table, because other subroutines of
    RelationBuildDesc also leak memory like mad.  Let's move the temp-context
    management into RelationBuildDesc so that leakage from the other
    subroutines is also recovered.
    
    I examined this issue by arranging for postgres.c to dump the size of
    MessageContext just before resetting it in each command cycle, and
    then running the update.sql regression test (which is one of the two
    that are seeing buildfarm OOMs) with and without CLOBBER_CACHE_ALWAYS.
    Before 2455ab48, the peak space usage with CCA was as much as 250MB.
    That patch got it down to ~80MB, but with this patch it's about 0.5MB,
    and indeed the space usage now seems nearly indistinguishable from a
    non-CCA build.
    
    RelationBuildDesc's traditional behavior of not worrying about leaking
    transient data is of many years' standing, so I'm pretty hesitant to
    change that without more evidence that it'd be useful in a normal build.
    (So far as I can see, non-CCA memory consumption is about the same with
    or without this change, whuch if anything suggests that it isn't useful.)
    Hence, configure the patch so that we recover space only when
    CLOBBER_CACHE_ALWAYS or CLOBBER_CACHE_RECURSIVELY is defined.  However,
    that choice can be overridden at compile time, in case somebody would
    like to do some performance testing and try to develop evidence for
    changing that decision.
    
    It's possible that we ought to back-patch this change, but in the
    absence of back-branch OOM problems in the buildfarm, I'm not in
    a hurry to do that.
    
    Discussion: https://postgr.es/m/CA+TgmoY3bRmGB6-DUnoVy5fJoreiBJ43rwMrQRCdPXuKt4Ykaw@mail.gmail.com
    d3f48dfa
relcache.c 189 KB