Re: Protect syscache from bloating with negative cache entries

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Andres Freund <andres(at)anarazel(dot)de>, "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Ideriha, Takeshi" <ideriha(dot)takeshi(at)jp(dot)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, David Steele <david(at)pgmasters(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: Protect syscache from bloating with negative cache entries
Date: 2019-03-06 18:09:15
Message-ID: CA+TgmobXDWanVtVjLpayQnWfyTd49ma4j1q71ek_Ce=Z9A2UBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 1, 2019 at 3:33 AM Kyotaro HORIGUCHI
<horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> > > It is artificial (or acutually wont't be repeatedly executed in a
> > > session) but anyway what can get benefit from
> > > catalog_cache_memory_target would be a kind of extreme.
> >
> > I agree. So then let's not have it.
>
> Ah... Yeah! I see. Andres' concern was that crucial syscache
> entries might be blown away during a long idle time. If that
> happens, it's enough to just turn off in the almost all of such
> cases.

+1.

> In the attached v18,
> catalog_cache_memory_target is removed,
> removed some leftover of removing the hard limit feature,
> separated catcache clock update during a query into 0003.
> attached 0004 (monitor part) in order just to see how it is working.
>
> v18-0001-Add-dlist_move_tail:
> Just adds dlist_move_tail
>
> v18-0002-Remove-entries-that-haven-t-been-used-for-a-certain-:
> Revised pruning feature.

OK, so this is getting simpler, but I'm wondering why we need
dlist_move_tail() at all. It is a well-known fact that maintaining
LRU ordering is expensive and it seems to be unnecessary for our
purposes here. Can't CatCacheCleanupOldEntries just use a single-bit
flag on the entry? If the flag is set, clear it. If the flag is
clear, drop the entry. When an entry is used, set the flag. Then,
entries will go away if they are not used between consecutive calls to
CatCacheCleanupOldEntries. Sure, that might be slightly less accurate
in terms of which entries get thrown away, but I bet it makes no real
difference.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-03-06 18:10:43 Re: patch to allow disable of WAL recycling
Previous Message Alvaro Herrera 2019-03-06 18:03:44 Re: pgsql: tableam: introduce table AM infrastructure.