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 1rri1e-002Bzw-TY for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 17:34:23 +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 1rri1b-00APlU-Ms for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 17:34:19 +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 1rri1a-00APlM-7h for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 17:34:19 +0000 Received: from fout5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rri1W-000GaI-B7 for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 17:34:17 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id F0FBB13800CE; Tue, 2 Apr 2024 13:34:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 02 Apr 2024 13:34:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712079251; x= 1712165651; bh=qpDxgGsu0a5ifnmzSZiftso1FeoYJCXCknjJuSXKeYg=; b=a 6Vcc6NU9qg94q9QUxIAirON3axJkykJgRdmZkgn8FGiycOTd085AS5VtlES1+xBH S2UCOaKVxgDAI8B6eDTuwoN+BB4S3V1SxVF9Jv9UPMAi1/18IhI4y+uGFk4fbA1p cFK0L/M7QAuCrW31MyYm8IU2meeTV3MCuAV3bwBHD1tgyckZaVK0cz5CCwr96lKJ m2qtPZOue0n4Ff7Z2v3Fznz6VVleSfFcNF32N+7twvEEQtm7ykCxoKbsOSBMey6j Vx+zFHbTMz9QXPOodzYQe2PG4rc0/ewIu5c5wyOr1nm93Olx7OGiu6Js+yfixeWE Xgo4x19vp1Q1YYE4LBY+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefvddgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeej keffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghl vhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Apr 2024 13:34:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1712079248; bh=k5G3h+UeMSsrjg6GQWweIcHq+hdzWfQk8deyZUFaqCk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=gxAIy+AGdH7tnzwwcT3C45QekYu4+cRuKL9EDaVHmAQglShSifY0JLf/KyhOFq+11 5hMQtvgHX317w5fzz2h7uW3MFkdtr8bOCABRrzWB232Redj9ZEQMabQ7yd/z+NL/a6 s9CLV5rLMIrWKcLWkfvF0LeWjSUlFgxo3hD1MFv0r13n/vR3FUssZjjB6gVfyuMaLv Hbl6znlwrrQsdIj8QGawAYcFw6AW3aZQqiXl0xWSBMk34ODgPnSWfJpotP0T3z/41X tIybGjAYZLuAhNrmpz4XtzLQ+J/p+R6ULf30BUVdPGBHhg8/A4ewqQiEGo++i3qUNq fsAdnro/S7/4Q== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 7AA0C41E; Tue, 2 Apr 2024 19:34:08 +0200 (CEST) Date: Tue, 2 Apr 2024 19:34:08 +0200 From: Alvaro Herrera To: Nathan Bossart Cc: Ants Aasma , "Amonson, Paul D" , Tom Lane , David Rowley , Andres Freund , "Shankaran, Akash" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <202404021734.635tuluozzn3@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240402155301.GA2750455@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Apr-02, Nathan Bossart wrote: > Another idea I had is to turn pg_popcount() into a macro that just uses the > pg_number_of_ones array when called for few bytes: > > static inline uint64 > pg_popcount_inline(const char *buf, int bytes) > { > uint64 popcnt = 0; > > while (bytes--) > popcnt += pg_number_of_ones[(unsigned char) *buf++]; > > return popcnt; > } > > #define pg_popcount(buf, bytes) \ > ((bytes < 64) ? \ > pg_popcount_inline(buf, bytes) : \ > pg_popcount_optimized(buf, bytes)) > > But again, I'm not sure this is really worth it for the current use-cases. Eh, that seems simple enough, and then you can forget about that case. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "No hay hombre que no aspire a la plenitud, es decir, la suma de experiencias de que un hombre es capaz"