RE: Protect syscache from bloating with negative cache entries - Mailing list pgsql-hackers

From Ideriha, Takeshi
Subject RE: Protect syscache from bloating with negative cache entries
Date
Msg-id 4E72940DA2BF16479384A86D54D0988A6F3D0D5F@G01JPEXMBKW04
Whole thread Raw
In response to RE: Protect syscache from bloating with negative cache entries  ("Ideriha, Takeshi" <ideriha.takeshi@jp.fujitsu.com>)
Responses Re: Protect syscache from bloating with negative cache entries
List pgsql-hackers
>From: Ideriha, Takeshi [mailto:ideriha.takeshi@jp.fujitsu.com]
>The detailed comments for the source code will be provided later.

Hi, 
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:
https://www.postgresql.org/docs/current/monitoring-stats.html

+pgstat_get_syscache_stats(PG_FUNCTION_ARGS) 
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.
    

Regards,
Takeshi Ideriha



pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: [HACKERS] Restricting maximum keep segments by repslots
Next
From: David Rowley
Date:
Subject: Re: Using POPCNT and other advanced bit manipulation instructions