Re: RFC: Improve CPU cache locality of syscache searches

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: RFC: Improve CPU cache locality of syscache searches
Date: 2021-08-18 18:19:21
Message-ID: CAFBsxsEiaaeqtRezs+5gwZNTbJhE+O3ZLVfp1uOed2-ui4k9Lw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

OK, here is a hackish WIP to see if we get anywhere with the L1 concept:

0001 is extracted from a patch from Horiguchi-san to remove the "dead" flag
0002 adds the large bucket, but doesn't use it for anything
0003 uses the new bucket for the L1 cache
0004 changes when to rehash
0005 is Horiguchi-san's v7 benchmark
0006 removes expiration stuff from the benchmark and prevents alloc errors
with my patches while running the benchmark

This doesn't align the bucket array to a cacheline boundary, nor does it
change the initial number of buckets

make -C contrib/catcachebench/ install
psql -c 'create extension catcachebench'

# This is also from Horiguchi-san
perl gen_tbl.pl | psql > /dev/null

# warmup
psql -c 'select catcachebench(0)'

# measure median of 3

master:

psql -c 'select catcachebench(1)'
catcachebench
---------------
6084.992169

patch:

./inst/bin/psql -c 'select catcachebench(1)'
catcachebench
---------------
5508.072532

That's decent, but not exactly stellar. I get a huge slowdown in
catcachebench(2), however, so I'll have to dig into why before going any
further.

Some time I'll also try the function specialization Andres mentioned and
see how big of a speedup that gives.

--
John Naylor
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
v1-0002-Specialize-bucket-types-by-number-of-keys.patch application/octet-stream 7.0 KB
v1-0001-Remove-dead-flag-from-CatCTup.patch application/octet-stream 6.2 KB
v1-0004-Rationalize-rehashing-threshold.patch application/octet-stream 1.7 KB
v1-0005-catcachebench.patch application/octet-stream 11.9 KB
v1-0003-Use-hash-bucket-as-a-level-one-cache-to-avoid-wal.patch application/octet-stream 5.3 KB
v1-0006-Some-adjustments-to-catcachebench-and-catcache.c-.patch application/octet-stream 4.4 KB
gen_tbl.pl text/x-perl-script 301 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2021-08-18 18:27:19 Re: [Patch] change the default value of shared_buffers in postgresql.conf.sample
Previous Message Bruce Momjian 2021-08-18 18:16:55 Re: [Patch] change the default value of shared_buffers in postgresql.conf.sample