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 1r0CDC-0045o6-Tm for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Nov 2023 02:53:06 +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 1r0CDB-003lJC-Fx for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Nov 2023 02:53:05 +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.94.2) (envelope-from ) id 1r0CDB-003lJ3-6J for pgsql-hackers@lists.postgresql.org; Tue, 07 Nov 2023 02:53:05 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r0CD9-0056O6-0d for pgsql-hackers@lists.postgresql.org; Tue, 07 Nov 2023 02:53:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3A72qwYA036330; Mon, 6 Nov 2023 21:52:58 -0500 From: Tom Lane To: Nathan Bossart cc: Matthias van de Meent , "Amonson, Paul D" , "pgsql-hackers@lists.postgresql.org" , "Shankaran, Akash" Subject: Re: Popcount optimization using AVX512 In-reply-to: <20231107022240.GA729644@nathanxps13> References: <20231107022240.GA729644@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Mon, 06 Nov 2023 20:22:40 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <36328.1699325578.1@sss.pgh.pa.us> Date: Mon, 06 Nov 2023 21:52:58 -0500 Message-ID: <36329.1699325578@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > Like I said, I don't have any proposals yet, but assuming we do want to > support newer intrinsics, either open-coded or via auto-vectorization, I > suspect we'll need to gather consensus for a new policy/strategy. Yeah. The function-pointer solution kind of sucks, because for the sort of operation we're considering here, adding a call and return is probably order-of-100% overhead. Worse, it adds similar overhead for everyone who doesn't get the benefit of the optimization. (One of the key things you want to be able to say, when trying to sell a maybe-it-helps-or-maybe-it-doesnt optimization to the PG community, is "it doesn't hurt anyone who's not able to benefit".) And you can't argue that that overhead is negligible either, because if it is then we're all wasting our time even discussing this. So we need a better technology, and I fear I have no good ideas about what. Your comment about vectorization hints at one answer: if you can amortize the overhead across multiple applications of the operation, then it doesn't hurt so much. But I'm not sure how often we can make that answer work. regards, tom lane