Re: Protect syscache from bloating with negative cache entries

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: michael(at)paquier(dot)xyz
Cc: tomas(dot)vondra(at)2ndquadrant(dot)com, robertmhaas(at)gmail(dot)com, ideriha(dot)takeshi(at)jp(dot)fujitsu(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, andres(at)anarazel(dot)de, tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com, alvherre(at)2ndquadrant(dot)com, bruce(at)momjian(dot)us, pgsql-hackers(at)lists(dot)postgresql(dot)org, michael(dot)paquier(at)gmail(dot)com, david(at)pgmasters(dot)net, craig(at)2ndquadrant(dot)com
Subject: Re: Protect syscache from bloating with negative cache entries
Date: 2020-11-05 07:26:55
Message-ID: 20201105.162655.1850883840029889601.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

The attached is the version that is compactified from the previous
version.

At Thu, 01 Oct 2020 16:47:18 +0900 (JST), Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote in
> This is the rebased version.

It occurred to me suddenly that static parameters to inline functions
causes optimization. I split SearchCatCacheInternal() into two
almost-the-same functions SearchCatCacheInternalb() and -e() until the
previous version but in turn I merged the two functions into the
original function and added a parameter "do_expire".

Then compared at machine-code level of the two deduced functions
SearchCatCache1b and SearchCatCache1e and confirmed that the
expiration-related code is eliminated from the former.

The lines prefixed by '+' are the instructions corresponding the
following C-code, which are eliminated in SearchCatCache1b.

0000000000002770 <SearchCatCache1e>:
2770: push %r15
2772: push %r14
...
2849: mov %rbp,(%rbx)
284c: mov %rbx,(%rax)
284f: mov %rbx,0x8(%rbp)
+ 2853: mov 0x30(%rbx),%eax # %eax = ct->naccess
+ 2856: mov $0x2,%edx
+ 285b: add $0x1,%eax # ct->access++
+ 285e: cmove %edx,%eax # if(ct->access == 0) %eax = 2
2861: xor %ebp,%ebp
2863: cmpb $0x0,0x15(%rbx) # (if (!ct->negative))
+ 2867: mov %eax,0x30(%rbx) # ct->access = %eax
+ 286a: mov 0x0(%rip),%rax # %rax = catcacheclock
+ 2871: mov %rax,0x38(%rbx) # ct->lastaccess = %rax
2875: jne 289a <SearchCatCache1e+0x12a>
2877: mov 0x0(%rip),%rdi

> if (do_expire)
> {
> ct->naccess++;
> if (unlikely(ct->naccess == 0))
> ct->naccess = 2;
> ct->lastaccess = catcacheclock;
> }

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
v3-0001-base_change.patch text/x-patch 5.0 KB
v3-0002-Make-CatCacheSearchN-indirect-functions.patch text/x-patch 6.4 KB
v3-0003-CatCache-expiration-feature.patch text/x-patch 10.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2020-11-05 08:24:08 Re: Move catalog toast table and index declarations
Previous Message yuzuko 2020-11-05 07:03:12 Re: Autovacuum on partitioned table (autoanalyze)