Re: Patch to address creation of PgStat* contexts with null parent context

From: Andres Freund <andres(at)anarazel(dot)de>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: reid(dot)thompson(at)crunchydata(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Patch to address creation of PgStat* contexts with null parent context
Date: 2022-08-08 19:20:20
Message-ID: 20220808192020.nc556tlgcp66fdgw@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2022-08-08 15:12:08 +0900, Kyotaro Horiguchi wrote:
> At Sat, 6 Aug 2022 19:19:39 -0700, Andres Freund <andres(at)anarazel(dot)de> wrote in
> > Hi,
> >
> > On 2022-08-05 17:22:38 +0900, Kyotaro Horiguchi wrote:
> > > I think it a bit different. Previously that memory (but for a bit
> > > different use, precisely) was required only when stats data is read so
> > > almost all server processes didn't need it. Now, every server process
> > > that uses pgstats requires the two memory if it is going to write
> > > stats. Even if that didn't happen until process termination, that
> > > memory eventually required to flush possibly remaining data. That
> > > final write might be avoidable but I'm not sure it's worth the
> > > trouble. As the result, calling pgstat_initialize() is effectively
> > > the declaration that the process requires the memory.
> >
> > I don't think every process will end up calling pgstat_setup_memcxt() -
> > e.g. walsender, bgwriter, checkpointer probably don't? What do we gain by
> > creating the contexts eagerly?
>
> Yes. they acutally does, in shmem_shutdown hook function, during
> at-termination stats write. I didn't consider to make that not
> happen, to save 2kB of memory on such small number of processes.

That's true for checkpointer, but not e.g. for walwriter, bgwriter. I don't
see why we should force allocate memory that we're never going to use in
background processes.

> And we don't hastle to avoid maybe-empty at-process-termination
> writes..

Hm?

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mikael Kjellström 2022-08-08 19:45:15 Re: conchuela doesn't like gnu_printf anymore
Previous Message Chris Cleveland 2022-08-08 19:04:01 Managing my own index partitions