Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tamOB-0052yI-Bu for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2025 01:52:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tamO9-008FNq-DS for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2025 01:52:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tamO8-008FNi-Up for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2025 01:52:09 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tamO5-0010zD-1X for pgsql-hackers@postgresql.org; Thu, 23 Jan 2025 01:52:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1737597121; bh=74V2+ZSmcl0uUMbnD24YZwQhN+D26OJ5mLz26b8tjIY=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=dRYLm+NcEe4gu4V3w/10HzgNRABUBuiea5vMrEOuex+4lTIYAgLoHxfpKF/F/C/IJ zNJvbcy+yP4A35l3RoSi9XVoXoRHR74Cd6wzC1mi6E2jUXPQ6OjKcyC7VAhZ9/mqRP o8rCHDh7AZG59qoHsquM60wunIDWQFDIhGAZ7KZ8cjwNi/y3XlVEUPVxH9f1sxoxE4 wKn68sQCAE7Is5lMCGrj4X6ZDT/vwsrA0LqWPajJkskpF1OvG9FIbDiVz6wNK8tcbg U9waBJ0CBKUltoPJfYubsgUvVpfvIdJKwVhwkNFQMiERkqkAS96Wp5rp7fU9K9vmC0 ZskTPb7csk1mQ== Received: from [172.30.48.146] (unknown [172.30.48.146]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.melnikov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id A725860EA3; Thu, 23 Jan 2025 04:52:01 +0300 (MSK) Message-ID: <4c739718-27d6-44fe-9113-56a251c13275@postgrespro.ru> Date: Thu, 23 Jan 2025 04:52:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Change GUC hashtable to use simplehash? To: John Naylor Cc: Tom Lane , Jeff Davis , Ants Aasma , Heikki Linnakangas , Junwang Zhao , jian he , Andres Freund , Gurjeet Singh , pgsql-hackers@postgresql.org References: <458350a908d9607f7fc2a15407f4405cc454c970.camel@j-davis.com> <2b0df3af97fac73a40aba16a58837e2cee594b1f.camel@j-davis.com> <0647027b-9c9a-4f16-8f7c-3f9f3eb9451e@postgrespro.ru> <1520769.1736991361@sss.pgh.pa.us> <16198d33-a4e2-46db-b6c3-494367f5816d@postgrespro.ru> Content-Language: en-US From: "Anton A. Melnikov" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected, bases: 2025/01/23 01:18:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/01/23 00:06:00 #27103179 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi! On 22.01.2025 11:37, John Naylor wrote: > On Fri, Jan 17, 2025 at 4:50 PM John Naylor wrote: >> >> It would be a lot more readable to revert the offending commit >> instead, since its predecessor had a much simpler bytewise loop. Agreed that reverting seems as a preferable way, and here's why. I found that this valgrind error during initdb first appeared after 0aba25544. At the previous e97b672c88 where there is no error i did a small experiment on my laptop. With -O2 compilation from src/backend/catalog/namespace.с:369 that really executes inlined spcachekey_hash() to src/backend/catalog/namespace.с:369 123 asm instructions are executed when hashing the string "pg_catalog". In the master at 630f9a43 the spcachekey_hash() is not inlined and asm call executes 204 asm inctructions at the same conditions. HAVE__BUILTIN_CTZ is defined on my pc so finding the first non-zero rightmost bit requires the only asm command. With patch v2-0001-Add-valgrind-safe-code the same will take 216 asm instructions. Of cause, if the common average length of a hashed string is known, can be performed experiments that better correspond to reality. But, it seems to me, there shouldn't be any considerably large strings here, so the general trend is clear. Please correct me if I'm wrong. With the best regards, -- Anton A. Melnikov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company