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.96) (envelope-from ) id 1vgIKr-00AXUJ-2r for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 08:04:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vgIKp-00FTkp-2f for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 08:04:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vgIKp-00FTka-13 for pgsql-hackers@lists.postgresql.org; Thu, 15 Jan 2026 08:04:03 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vgIKn-000a4J-1c for pgsql-hackers@lists.postgresql.org; Thu, 15 Jan 2026 08:04:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1768464239; bh=dowykin885ksGpF9UB3xpfyTC5gPEdE8EY06CGKXEjY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID:From; b=XmCvohiHKNi4XKOSQr3nUkTf1n6cjNbg0zMnlv+l7Tkc4IJ/f4BGUlQ7Dntzk3//F Zx7VXv7hpTOFBHT/49xzjdyLi+QvCG9t/VDAS3QELjNf7inXTCWr4TVyxasExMEZUs +r/BHxlERUK1aTpAgbuTnEi+ey0oEaGbsjnLFpXYUygkNJwguPAfJNyhwj57LKy9Dx np7p4lEmi+MmT8b9ZDryd3Lb3KfrUwb8/LtQ6T3sLnirdZMqodsLoGXYpcMpytHdRK Z1D8vTb7Y7mB5PUl+TTKGR3xiWORUUdxwTZgCx7XFiDORtsymGn7Re5zqw0I7Nacip UphcvNWRoWPiQ== Received: from mail.l.postgrespro.ru (webmail-slave-mstn.l.postgrespro.ru [192.168.2.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: o.tselebrovskiy@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id B81C26016F; Thu, 15 Jan 2026 11:03:59 +0300 (MSK) MIME-Version: 1.0 Date: Thu, 15 Jan 2026 15:03:59 +0700 From: Oleg Tselebrovskiy To: John Naylor Cc: Andrew Kim , pgsql-hackers@lists.postgresql.org Subject: Re: Proposal for enabling auto-vectorization for checksum calculations In-Reply-To: References: <20250911054220.3784-1-root@ip-172-31-36-228.ec2.internal> Message-ID: <0be1b7b05726652ea0d83e8f72fd4cfe@postgrespro.ru> X-Sender: o.tselebrovskiy@postgrespro.ru Organization: Postgres Pro Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected 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: 2026/01/15 05:59:00 #28115885 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 Can't respond to the original message about v10 of the patch for some reason, so I'll respond here. > So in v10 I separated the body of checksum_block to > a semi-private header to provide hardware-specific definitions > for core code, while also maintaining the same one that > external code expects I like the usage of a semi-internal header, less code duplication is always good > In the attached v10-0003, I went back to something more similar to v6, > but incorporated Andrew's idea of using PG_CHECKSUM_INTERNAL to allow > for flexibility. Now pg_filedump compiles without any changes, so > that's a plus. If I understand correctly, with how code is currently, external programms can define PG_CHECKSUM_INTERNAL manually, but then they won't have access to static functions inside of checksum.c, so all you get is a pointer that leads nowhere, correct? I'd like to think that speeding up checksum calculation is something that some external programms could appreciate. Is it possible to move pg_checksum_block_fallback, pg_checksum_block_avx2, and pg_checksum_choose to checksum_impl.h? It would mean moving all the hardware check to the same header as well. Doesn't look or sound pretty, but this would allow external programms to chose implementation the same way the core does it, but also just change nothing and still have fallback code. > For this to be commitable, I think (and I think Oleg agrees) that the > feature detection should go in src/port. Some of us have been thinking > of refactoring and centralizing the feature detection, and now may be > a good time to do it. I do agree with that. I thought that we can continue with v10 as-is, commit it with hardware checks still in checksum.c and refactor it with everything else, but with my proposition above (and even without it) it seems that refactoring of hardware checks should come first. Also, not moving all those checksum files to src/port saves us from thinking about problems with meson and current external programs, but, I think, that after hardware checks are refactored, we could revisit the question of moving checksum[_impl].h/.c to src/port. All in all, very happy to see progress on this! Regards, Oleg