RE: Protect syscache from bloating with negative cache entries

From: "Ideriha, Takeshi" <ideriha(dot)takeshi(at)jp(dot)fujitsu(dot)com>
To: 'Kyotaro HORIGUCHI' <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, "alvherre(at)alvh(dot)no-ip(dot)org" <alvherre(at)alvh(dot)no-ip(dot)org>, "andres(at)anarazel(dot)de" <andres(at)anarazel(dot)de>, "robertmhaas(at)gmail(dot)com" <robertmhaas(at)gmail(dot)com>, "michael(dot)paquier(at)gmail(dot)com" <michael(dot)paquier(at)gmail(dot)com>, "david(at)pgmasters(dot)net" <david(at)pgmasters(dot)net>, "Jim(dot)Nasby(at)bluetreble(dot)com" <Jim(dot)Nasby(at)bluetreble(dot)com>, "craig(at)2ndquadrant(dot)com" <craig(at)2ndquadrant(dot)com>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: RE: Protect syscache from bloating with negative cache entries
Date: 2018-12-20 07:56:16
Message-ID: 4E72940DA2BF16479384A86D54D0988A6F3D0D5F@G01JPEXMBKW04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>From: Ideriha, Takeshi [mailto:ideriha(dot)takeshi(at)jp(dot)fujitsu(dot)com]
>The detailed comments for the source code will be provided later.

I'm adding some comments to 0001 and 0002 one.

[0001 patch]

+ /*
+ * Calculate the duration from the time of the last access to the
+ * "current" time. Since catcacheclock is not advanced within a
+ * transaction, the entries that are accessed within the current
+ * transaction won't be pruned.
+ */
+ TimestampDifference(ct->lastaccess, catcacheclock, &entry_age, &us);

+ /*
+ * Try to remove entries older than cache_prune_min_age seconds.

+ if (entry_age > cache_prune_min_age)

Can you change this comparison between entry_age and cache_prune_min_age
to "entry_age >= cache_prune_min_age"?
That is, I want the feature that entries that are accessed even within the transaction
is pruned in case of cache_prune_min_age = 0
I can hit upon some of my customer who want to always keep memory usage below certain limit as strictly as possible.
This kind of strict user would set cache_prune_min_age to 0 and would not want to exceed the memory target even
if within a transaction.

As I put miscellaneous comments about 0001 patch in some previous email, so please take a look at it.

[0002 patch]
I haven't looked into every detail but here are some comments.

Maybe you would also need to add some sentences to this page:

Function name like 'pg_stat_XXX' would match surrounding code.

When applying patch I found trailing whitespace warning:
../patch/horiguchi_cache/v6_stats/0002-Syscache-usage-tracking-feature.patch:157: trailing whitespace.

../patch/horiguchi_cache/v6_stats/0002-Syscache-usage-tracking-feature.patch:256: trailing whitespace.

../patch/horiguchi_cache/v6_stats/0002-Syscache-usage-tracking-feature.patch:301: trailing whitespace.

../patch/horiguchi_cache/v6_stats/0002-Syscache-usage-tracking-feature.patch:483: trailing whitespace.

../patch/horiguchi_cache/v6_stats/0002-Syscache-usage-tracking-feature.patch:539: trailing whitespace.

Takeshi Ideriha

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-12-20 08:10:44 Re: Using POPCNT and other advanced bit manipulation instructions
Previous Message Kyotaro HORIGUCHI 2018-12-20 07:24:38 Re: [HACKERS] Restricting maximum keep segments by repslots