Re: Change GUC hashtable to use simplehash?

From: "Anton A(dot) Melnikov" <a(dot)melnikov(at)postgrespro(dot)ru>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Ants Aasma <ants(dot)aasma(at)cybertec(dot)at>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gurjeet Singh <gurjeet(at)singh(dot)im>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Change GUC hashtable to use simplehash?
Date: 2025-01-16 01:15:31
Message-ID: 0647027b-9c9a-4f16-8f7c-3f9f3eb9451e@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, John!

On 19.12.2024 12:48, John Naylor wrote:
> That would actually be a maintenance headache because the function is
> inlined, but here's a better idea: We already have a fallback path for
> when the string is not suitably aligned, or in 32-bit builds. We could
> just use that under Valgrind:
>
> static inline size_t
> fasthash_accum_cstring(fasthash_state *hs, const char *str)
> {
> -#if SIZEOF_VOID_P >= 8
> +#if SIZEOF_VOID_P >= 8 && !defined(USE_VALGRIND)
>
> Any objections?

This variant doesn't produce error and helped me to move
further beyond initdb in the some tests under valgrind
and fix a number of bugs.
Thank you very much!

Seems it is possible to exclude much less code from checking
under valgrind and get the same result by replacing the only
function call pg_rightmost_one_pos64() with a valgrind-safe
code. See the attached patch, please.

The pg_rightmost_one_pos64() itself can also be valgrind-safe
in some cases when the last version of its code works.
But i'm not sure if it's worth writing extra preprocessor instructions
to make this small piece of code also checkable under valgrind.
So in the patch i made a simple variant without it.

With the best wishes,

--
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
v1-0001-Add-valgrind-safe-code-to-find-rightmost-bytes.patch text/x-patch 1.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-01-16 01:18:44 Re: convert libpgport's pqsignal() to a void function
Previous Message Ranier Vilela 2025-01-16 01:12:51 Fix misuse use of pg_b64_encode function (contrib/postgres_fdw/connection.c)