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 1vgPti-00C7WJ-1k for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 16:08:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vgPth-000RXW-2P for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 16:08:33 +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.96) (envelope-from ) id 1vgPth-000RWz-1T for pgsql-hackers@lists.postgresql.org; Thu, 15 Jan 2026 16:08:33 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vgPtS-000acI-0p for pgsql-hackers@postgresql.org; Thu, 15 Jan 2026 16:08:32 +0000 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-7cfd48df0afso697970a34.1 for ; Thu, 15 Jan 2026 08:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768493298; x=1769098098; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DFWoD4vIezBbeVXWDE9T6jGifViliiXb+40X1WU+S4A=; b=KhhayPUNoFDG0nvFk5meCA3iKYUXeQOfjsKph7+ilfM9F+PF2w+RX17x7CBcbO4fJf /M9Sz+G3ZDcBZMqhrq/BFTDhodeJOX+d0ECZLt8QbS4xlpJLLzapnXgWlXl6Id6ZtXkL oRkHck2itbo0gWr/UpTvrAsdl3/YH+0mojU4ux3Vea20ZTFaTXQSb4J5Fuj1XvQ7i6Ck 8N2XDAuYMCh1ayPpvpdRAyK9YbjQmjqR3slxiHar91DLGLJIbjczdnG+KgfARZnn9giN DV66MFZ5zXmJA8faHCkwSxKF/cFLjg4p+COYLhXQuGM23IfkI3pqzVpjfkCNQgyYS46T /hsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768493298; x=1769098098; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DFWoD4vIezBbeVXWDE9T6jGifViliiXb+40X1WU+S4A=; b=ne0GBocV/kCGj9+5HviL6x0Jeeyb/L3J0EO36tiDlENrEVGjTJDE+wDCbGHGO+nRYr oRJe/Fuw5i+bZVvkCuH+uKvj6sltylVC9Mq0BsUYOJeIf4PL7UnmNzxIYNX0IPWCtUnZ k5YQIZlnnuxOTvyDW9O++UOpiysMNt0fVL2b70qaQkFeGcVSQAfMKYkqvwuZrwTAaRK2 pvCmI+CaPF8RbsD+0PDhK83jnETXInx1keoSPUuiW5Kyiz8Pi4AbakIjecbtlidIj+Ic Oa7EdIgc/lqkfu7oAKp36OuNScJ8vhjxPOxtFAuX+TppVQfRVv2QKr2wulw8STUEFg10 sylA== X-Forwarded-Encrypted: i=1; AJvYcCVPWrkyCJfwPMjxSSECYNOE64qZF3i/Q2IoiyN19x2d8/HEKVNp0NvgM6EaIXeBNOclvRXDqgqBcVDZOKxG@postgresql.org X-Gm-Message-State: AOJu0Yy24AGvNc9Hwr/jaAv4pWR8gHourzbBWQhiWujYDh4VtOwimjD8 OGU6+D4cUs/djFRyxMI2mcUmtMRqYts2eCNXf2HYDIDs6+a9Mp8zoBpZ X-Gm-Gg: AY/fxX4pbSiFf7BE2GvXBkajZT918oxnRTb2jN2dIKSClBdPTBpz01i0ijOywh/5zAt uUTnMJrlRwir1V9Ls23i3v6vYD8d/zXZMKRORPn+cDrGv7LiNjsi9tuVa4HGNFwYBUNLiMs3kwD 8UWl5IIt2N9cOAr5XGD7rwnXaXGtp4DKM8MeSgbLoTJW2ARk9YvKvZF+Q8uS8sPH0wKvm1YOnir YDzdBsYMzRptnii8jw63PiUI4EDdE9nltVou99NfGwjanDPdb0TZuCu8W2jpHi91rQE0NPNUWcy WdlgZZUO4NIPqJ4DoDqY3+ApeCZcXwHKyK8PPcCKQhjwES3Hk4MzTsfCJq5L2dZVTBt1qwRAxt3 rOjBAsGkncPPI4hDpVr8QQsxAdWZt4C0m7+HjrH7iIcl63zwWO886ZBptZX4gcttSZ4ORakg64G RVl0OI9NkfOAYqUZrWV74v5c8NiXaudm/5BF6EuQVS94h6vKsFSad8CH0tcR3TfPl85TMjRQdr3 43w X-Received: by 2002:a05:6830:4c07:b0:7c9:5b7c:8a33 with SMTP id 46e09a7af769-7cfcb67f9a2mr5387817a34.19.1768493298232; Thu, 15 Jan 2026 08:08:18 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cfd0f2e4bdsm2753428a34.20.2026.01.15.08.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jan 2026 08:08:17 -0800 (PST) Date: Thu, 15 Jan 2026 10:08:16 -0600 From: Nathan Bossart To: Heikki Linnakangas Cc: John Naylor , pgsql-hackers@postgresql.org Subject: Re: refactor architecture-specific popcount code Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 15, 2026 at 11:42:14AM +0200, Heikki Linnakangas wrote: > On 15/01/2026 11:07, John Naylor wrote: >> s/slow/generic/: >> >> I'm ambivalent about this. The "slow" designation is flat-out wrong >> since at least Power and aarch64 can emit a single instruction here >> without prodding the compiler. On the other hand, "generic" seems >> wrong too, since e.g. pg_popcount64_slow() has three configure symbols >> and two compiler builtins. :-D > > "fallback", or "portable" ? I've no strong opinions, but "portable" seems reasonable to me. > Yeah, I noticed that on x86_64, pg_popcount_optimized is always a function > pointer with runtime check, even if you use compiler flags to target a CPU > where the special instructions are available unconditionally. I wonder how close we are to being able to just require SSE4.2/POPCNT for x86-64 builds. I suppose there's always a chance that someone will try to run Postgres 19 on a CPU from the aughts... In any case, avoiding the function pointer when possible seems like a good follow-up. -- nathan