pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: John Naylor <johncnaylorls@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Gurjeet Singh <gurjeet@singh.im>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Change GUC hashtable to use simplehash?
Date: Sat, 09 Dec 2023 11:18:15 -0800
Message-ID: <b40292c99e623defe5eadedab1d438cf51a4107c.camel@j-davis.com> (raw)
In-Reply-To: <CANWCAZaJrQ9esBQuQ46YoXMeAm0eRqyED2SMJMUxfCOoDKyrnA@mail.gmail.com>
References: <c95e1821b6a69ec0c40eb0252e037b68a62cdae3.camel@j-davis.com>
	<20231117232712.mpnzsho7ydssg2oc@awork3.anarazel.de>
	<7fee9f31c2e82948fa56fe57d68eecb0cce36f10.camel@j-davis.com>
	<20231118001003.n2d7tvdgeckun2y6@awork3.anarazel.de>
	<27a7a289d5b8f42e1b1e79b1bcaeef3a40583bd2.camel@j-davis.com>
	<CANWCAZY7Cr-GdUhrCLoR4+JGLChTb0pQxq9ZPi1KTLs+_KDFqg@mail.gmail.com>
	<20231122205030.v6yllmmj6dgxpg5f@awork3.anarazel.de>
	<2330615.1700686581@sss.pgh.pa.us>
	<20231122212221.ahmlio2yfx7jla6z@awork3.anarazel.de>
	<2334462.1700688476@sss.pgh.pa.us>
	<20231122223432.lywt4yz2bn7tlp27@awork3.anarazel.de>
	<CANWCAZYDNjTh=8FxgZKmS8HEE=wcmLMoJx+Vvg3+xgAaGY=2oQ@mail.gmail.com>
	<CANWCAZb_17xdPP7v1_mXXg5TVbWkDzkP_WDgbCWpqUvz_VZ+OQ@mail.gmail.com>
	<40718ab2acf2af7a495a33f6f6f07b876b49635d.camel@j-davis.com>
	<CANWCAZaJrQ9esBQuQ46YoXMeAm0eRqyED2SMJMUxfCOoDKyrnA@mail.gmail.com>

On Sat, 2023-12-09 at 18:52 +0700, John Naylor wrote:
> > I tested using the new hash function APIs for my search path cache,
> > and
> > there's a significant speedup for cases not benefiting from
> > a86c61c9ee.
> > It's enough that we almost don't need a86c61c9ee. So a definite +1
> > to
> > the new APIs.
> 
> Do you have a new test?

Still using the same basic test here:

https://www.postgresql.org/message-id/04c8592dbd694e4114a3ed87139a7a04e4363030.camel%40j-davis.com

What I did is:

   a. add your v5 patches
   b. disable optimization in a86c61c9ee
   c. add attached patch to use new hash APIs

I got a slowdown between (a) and (b), and then (c) closed the gap about
halfway. It started to get close to test noise at that point -- I could
get some better numbers out of it if it's helpful.

Also, what I'm doing in the attached path is using part of the key as
the seed. Is that a good idea or should the seed be zero or come from
somewhere else?

Regards,
	Jeff Davis

Attachments:

v1-0001-Use-new-hash-APIs-for-search-path-cache.patch (text/x-patch, 1.3K) download From a30e5f0ea580fb5038eb90e862f697b557627f32 Mon Sep 17 00:00:00 2001 From: Jeff Davis <jeff@j-davis.com> Date: Fri, 8 Dec 2023 12:14:27 -0800 Subject: [PATCH v1] Use new hash APIs for search path cache --- src/backend/catalog/namespace.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 5027efc91d..af815a889d 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -42,6 +42,7 @@ #include "catalog/pg_type.h" #include "commands/dbcommands.h" #include "common/hashfn.h" +#include "common/hashfn_unstable.h" #include "funcapi.h" #include "mb/pg_wchar.h" #include "miscadmin.h" @@ -247,11 +248,18 @@ static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames, static inline uint32 spcachekey_hash(SearchPathCacheKey key) { - const unsigned char *bytes = (const unsigned char *) key.searchPath; - int blen = strlen(key.searchPath); + const char *buf = key.searchPath; + fasthash64_state hs; - return hash_combine(hash_bytes(bytes, blen), - hash_uint32(key.roleid)); + fasthash64_init(&hs, key.roleid); + + while (*buf) + { + fasthash64_accum_byte(&hs, *buf); + buf++; + } + + return fasthash64_final32(&hs); } static inline bool -- 2.34.1

view thread (103+ messages)  latest in thread

Message-ID: <b40292c99e623defe5eadedab1d438cf51a4107c.camel@j-davis.com>
Permalink:  ../b40292c99e623defe5eadedab1d438cf51a4107c.camel@j-davis.com/
Also on:    postgresql.org/message-id/b40292c99e623defe5eadedab1d438cf51a4107c.camel@j-davis.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: pgsql@j-davis.com, johncnaylorls@gmail.com, andres@anarazel.de, tgl@sss.pgh.pa.us, gurjeet@singh.im
  Subject: Re: Change GUC hashtable to use simplehash?
  In-Reply-To: <b40292c99e623defe5eadedab1d438cf51a4107c.camel@j-davis.com>
  References: <c95e1821b6a69ec0c40eb0252e037b68a62cdae3.camel@j-davis.com> <20231117232712.mpnzsho7ydssg2oc@awork3.anarazel.de> <7fee9f31c2e82948fa56fe57d68eecb0cce36f10.camel@j-davis.com> <20231118001003.n2d7tvdgeckun2y6@awork3.anarazel.de> <27a7a289d5b8f42e1b1e79b1bcaeef3a40583bd2.camel@j-davis.com> <CANWCAZY7Cr-GdUhrCLoR4+JGLChTb0pQxq9ZPi1KTLs+_KDFqg@mail.gmail.com> <20231122205030.v6yllmmj6dgxpg5f@awork3.anarazel.de> <2330615.1700686581@sss.pgh.pa.us> <20231122212221.ahmlio2yfx7jla6z@awork3.anarazel.de> <2334462.1700688476@sss.pgh.pa.us> <20231122223432.lywt4yz2bn7tlp27@awork3.anarazel.de> <CANWCAZYDNjTh=8FxgZKmS8HEE=wcmLMoJx+Vvg3+xgAaGY=2oQ@mail.gmail.com> <CANWCAZb_17xdPP7v1_mXXg5TVbWkDzkP_WDgbCWpqUvz_VZ+OQ@mail.gmail.com> <40718ab2acf2af7a495a33f6f6f07b876b49635d.camel@j-davis.com> <CANWCAZaJrQ9esBQuQ46YoXMeAm0eRqyED2SMJMUxfCOoDKyrnA@mail.gmail.com> <b40292c99e623defe5eadedab1d438cf51a4107c.camel@j-davis.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox