Re: pgsql: Introduce hash_search_with_hash_value() function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Introduce hash_search_with_hash_value() function
Date: 2024-08-07 06:34:21
Message-ID: CAFj8pRBN65zcR62uOy+wbM61yVJ0P7G-m6tgZZc3NVQRsCz5nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Hi

st 7. 8. 2024 v 6:08 odesílatel Alexander Korotkov <akorotkov(at)postgresql(dot)org>
napsal:

> Introduce hash_search_with_hash_value() function
>
> This new function iterates hash entries with given hash values. This
> function
> is designed to avoid full sequential hash search in the syscache
> invalidation
> callbacks.
>
> Discussion:
> https://postgr.es/m/5812a6e5-68ae-4d84-9d85-b443176966a1%40sigaev.ru
> Author: Teodor Sigaev
> Reviewed-by: Aleksander Alekseev, Tom Lane, Michael Paquier, Roman Zharkov
> Reviewed-by: Andrei Lepikhov
>

I tried to use hash_seq_init_with_hash_value in session variables patch,
but it doesn't work there.

<-->if (!sessionvars)
<--><-->return;

elog(NOTICE, "%u", hashvalue);

<-->hash_seq_init(&status, sessionvars);

<-->while ((svar = (SVariable) hash_seq_search(&status)) != NULL)
<-->{
<--><-->if (hashvalue == 0 || svar->hashvalue == hashvalue)
<--><-->{
<--><--><-->elog(NOTICE, "FOUND OLD");
<--><--><-->svar->is_valid = false;
<--><-->}
<-->}

<-->/*
<--> * If the hashvalue is not specified, we have to recheck all currently
<--> * used session variables. Since we can't tell the exact session
variable
<--> * from its hashvalue, we have to iterate over all items in the hash
bucket.
<--> */
<-->if (hashvalue == 0)
<--><-->hash_seq_init(&status, sessionvars);
<-->else
<--><-->hash_seq_init_with_hash_value(&status, sessionvars, hashvalue);

<-->while ((svar = (SVariable) hash_seq_search(&status)) != NULL)
<-->{
<--><-->Assert(hashvalue == 0 || svar->hashvalue == hashvalue);

elog(NOTICE, "found");

<--><-->svar->is_valid = false;
<--><-->needs_validation = true;
<-->}
}

Old methods found an entry, but new not.

What am I doing wrong?

Regards

Pavel

> Branch
> ------
> master
>
> Details
> -------
>
> https://git.postgresql.org/pg/commitdiff/d0f020037e19c33c74d683eb7e0c7cc5725294b4
>
> Modified Files
> --------------
> src/backend/utils/hash/dynahash.c | 38
> ++++++++++++++++++++++++++++++++++++++
> src/include/utils/hsearch.h | 5 +++++
> 2 files changed, 43 insertions(+)
>
>

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2024-08-07 07:28:40 pgsql: Revert ECPG's use of pnstrdup()
Previous Message Alexander Korotkov 2024-08-07 04:08:11 pgsql: Optimize InvalidateAttoptCacheCallback() and TypeCacheTypCallbac

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-08-07 06:56:30 Remove TRACE_SORT macro?
Previous Message Amit Kapila 2024-08-07 06:17:42 Re: Fix memory counter update in reorderbuffer