Re: Protect syscache from bloating with negative cache entries

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, 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>, Bruce Momjian <bruce(at)momjian(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-07 15:01:37
Message-ID: CA+Tgmobjc7EnHePr4T-gsYdj8tvqY4a3L7wxA7SjH7UC16Q4pw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 7, 2019 at 9:49 AM Tomas Vondra
<tomas(dot)vondra(at)2ndquadrant(dot)com> wrote:
> I don't think this shows any regression, but perhaps we should do a
> microbenchmark isolating the syscache entirely?

Well, if we need the LRU list, then yeah I think a microbenchmark
would be a good idea to make sure we really understand what the impact
of that is going to be. But if we don't need it and can just remove
it then we don't.

> What I had in mind is more along these lines:
>
> (a) track number of active syscache entries (increment when adding a new
> one, decrement when evicting one)
>
> (b) track peak number of active syscache entries
>
> (c) after clock-sweep, if (peak > K*active) where K=2 or K=4 or so, do a
> memory context swap, i.e. create a new context, copy active entries over
> and destroy the old one
>
> That would at least free() the memory. Of course, the syscache entries
> may have different sizes, so tracking just numbers of entries is just an
> approximation. But I think it'd be enough.

Yeah, that could be done. I'm not sure how expensive it would be, and
I'm also not sure how much more effective it would be than what's
currently proposed in terms of actually freeing memory. If you free
enough dead syscache entries, you might manage to give some memory
back to the OS: after all, there may be some locality there. And even
if you don't, you'll at least prevent further growth, which might be
good enough.

We could consider doing some version of what has been proposed here
and the thing you're proposing here could later be implemented on top
of that. I mean, evicting entries at all is a prerequisite to
copy-and-compact.

--
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-07 15:03:50 Re: New vacuum option to do only freezing
Previous Message Robert Haas 2019-03-07 14:53:16 Re: [PROPOSAL] Drop orphan temp tables in single-mode