Re: resowner "cold start" overhead

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: andres(at)anarazel(dot)de
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: resowner "cold start" overhead
Date: 2022-10-31 02:28:31
Message-ID: 20221031.112831.1522963582211139185.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Sat, 29 Oct 2022 13:00:25 -0700, Andres Freund <andres(at)anarazel(dot)de> wrote in
> One way to reduce the size increase would be to use the space for initialarr
> to store variables we don't need while initialarr is used. E.g. itemsarr,
> maxitems, lastarr are candidates. But I suspect that the code complication
> isn't worth it.

+1

> A different approach could be to not go for the "embedded initial elements"
> approach, but instead to not delete resource owners / resource arrays inside
> ResourceOwnerDelete(). We could stash them in a bounded list of resource
> owners, to be reused by ResourceOwnerCreate(). We do end up creating a
> several resource owners even for the simplest queries.

We often do end up creating several resource owners that aquires not
an element at all . On the other hand, a few resource owners
sometimes grown up to 2048 (several times) or 4096 (one time) elements
druing a run of the regressiont tests. (I saw catlist, tupdesc and
relref grown to 2048 or more elements.)

> The advantage of that scheme is that it'd save more and that we'd only reserve
> space for ResourceArrays that are actually used in the current workload -
> often the majority of arrays won't be.

Thus I believe preserving resource owners works well. Preserving
resource arrays also would work for the time efficiency, but some
resource owners may end up keeping large amount of memory
unnecessarily most of the time for the backend lifetime. I guess that
the amount is far less than the possible bloat by catcache..

> A potential problem would be that we don't want to use the "hashing" style
> ResourceArrays forever, I don't think they'll be as fast for other cases. But
> we could reset the arrays when they get large.

I'm not sure linear search (am I correct?) doesn't harm for 2048 or
more elements. I think that the "hashing" style doesn't prevent the
arrays from being reset (free-d) at transaction end (or at resource
owner deletion). That allows releasing unused elements while in
transaction but I'm not sure we need to be so keen to reclaim space
during a transaction.

> Greetings,
>
> Andres Freund
>
> https://www.postgresql.org/message-id/20221029025420.eplyow6k7tgu6he3%40awork3.anarazel.de

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2022-10-31 02:48:01 Lock on ShmemVariableCache fields?
Previous Message Maciek Sakrejda 2022-10-31 01:08:55 Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)