From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: andres@anarazel.de <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Cc: Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
Cc: michael.paquier@gmail.com <michael.paquier@gmail.com>
Cc: david@pgmasters.net <david@pgmasters.net>
Cc: craig@2ndquadrant.com <craig@2ndquadrant.com>
Subject: Re: Protect syscache from bloating with negative cache entries
Date: Tue, 5 Feb 2019 19:05:26 -0300
Message-ID: <20190205220526.GA1442@alvherre.pgsql> (raw)
In-Reply-To: <0d3806bf-5087-a75f-3592-ee1d508a79db@2ndquadrant.com>
On 2019-Feb-05, Tomas Vondra wrote:
> I don't think we need to remove the expired entries right away, if there
> are only very few of them. The cleanup requires walking the hash table,
> which means significant fixed cost. So if there are only few expired
> entries (say, less than 25% of the cache), we can just leave them around
> and clean them if we happen to stumble on them (although that may not be
> possible with dynahash, which has no concept of expiration) of before
> enlarging the hash table.
I think seqscanning the hash table is going to be too slow; Ideriha-san
idea of having a dlist with the entries in LRU order (where each entry
is moved to head of list when it is touched) seemed good: it allows you
to evict older ones when the time comes, without having to scan the rest
of the entries. Having a dlist means two more pointers on each cache
entry AFAIR, so it's not a huge amount of memory.
> So if we want to address this case too (and we probably want), we may
> need to discard the old cache memory context someho (e.g. rebuild the
> cache in a new one, and copy the non-expired entries). Which is a nice
> opportunity to do the "full" cleanup, of course.
Yeah, we probably don't want to do this super frequently though.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, tomas.vondra@2ndquadrant.com, bruce@momjian.us, andres@anarazel.de, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, horiguchi.kyotaro@lab.ntt.co.jp, ideriha.takeshi@jp.fujitsu.com, pgsql-hackers@lists.postgresql.org, tsunakawa.takay@jp.fujitsu.com, michael.paquier@gmail.com, david@pgmasters.net, craig@2ndquadrant.com
Subject: Re: Protect syscache from bloating with negative cache entries
In-Reply-To: <20190205220526.GA1442@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox