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 1rsQjV-0070Sq-TK for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2024 17:18:38 +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 1rsQjU-009iR5-6X for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2024 17:18:36 +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 1rsQjT-009iQx-R1 for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2024 17:18:35 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rsQjQ-000dYW-JX for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2024 17:18:35 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-5f034b4dcecso914424a12.1 for ; Thu, 04 Apr 2024 10:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712251110; x=1712855910; darn=lists.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=lI7WmJuukrNsCkDQ2b6xPwNj/e6yK9o3BTgkJKHu1r4=; b=m2Y0/nYWESvLFIGPiQqgjjQ+eRE/sUfWFOKRPXC/GJvQA9vOybv1ETGI3RKjT3QqUC zEhyAnsnLb8/hrw6+MNvJZl1ZVsyO9Xd44tcH4Ym47+aWBEdce8dG46nr0dWiOTAt/C6 tPOTSP1tCpxQ/9wCaYUZLIYA5RhsNFcXbX7OMOycusysQrBeKL1qrqEn3O1kgH5Tpy1R fFwL4zptGUEAqTb2bGi2HSswpwD1rin7A+v45DEgP93g1pyo/WH2WCXFH7VGGonZJKFQ yldk0bLGSPpgoaltdAVz9QQoXd7+WEjSXuWynCxKSr65NPUIksKRJ+X4eYJ8c02w9xDv /WQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712251110; x=1712855910; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lI7WmJuukrNsCkDQ2b6xPwNj/e6yK9o3BTgkJKHu1r4=; b=AZpu2JDH/O3zKtCHNJWTbKZrrbeuQvmvdXYfj2PCOecV1nH3twBT68qBfg/oY/gP3t ZFLxIOqSZIxKEdHE1T4PjXUaF0bR0OJpigAT2jvfkeSLYjJLypW/iT1/fBFIeYoVG9m8 fli0rryTejrBPR8E52XaiL634kutKCWAbhTs5QtjJfiY1Rn9plkvf04KPCMzchESnuUv 94yJooMqGHvCLDmVme6IEfrh5hYy/SsZxix9/hP4SOtRt9ZsM9ph2evnYkbN1/yqSsqb bqWLESk2qQwq9Gj4i+8oZzVq+7Yaxqn51vZLgUTzRPtSu/KNdeYKE5brFcCZpgGeIWJE Hf4w== X-Forwarded-Encrypted: i=1; AJvYcCUtPIhf88G0swttiYuTdq+auIxIDOOq+ebcESmhHQjh7CEzZdk6TQMr3b6ijUejtxQfQahaxwOxmI2HHhBpq/iTvE74a/7pKeimacnRdJVp0ZEC X-Gm-Message-State: AOJu0YzmtSGVXlE0vThwj1CqRK0WAAuoEbSRPCZl5t3PLxHt7FEWdUdN 2gqivAon7tsCyFsInzpRanJoWGt8FKFz+h7JfQqScX5PChK3v2a2 X-Google-Smtp-Source: AGHT+IFe2MRKTGE+T6OfIFymfr7yW28XWDyFv04tiHX23IgK37ZSuhId+GlQni0fLCUWgdiBDiro0Q== X-Received: by 2002:a17:90a:7c43:b0:2a2:f249:6180 with SMTP id e3-20020a17090a7c4300b002a2f2496180mr194445pjl.18.1712251110431; Thu, 04 Apr 2024 10:18:30 -0700 (PDT) Received: from nathanxps13 ([64.124.160.6]) by smtp.gmail.com with ESMTPSA id j11-20020a17090ae60b00b0029c19285192sm1779346pjy.44.2024.04.04.10.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 10:18:30 -0700 (PDT) Date: Thu, 4 Apr 2024 12:18:28 -0500 From: Nathan Bossart To: David Rowley Cc: Ants Aasma , Alvaro Herrera , "Amonson, Paul D" , Tom Lane , Andres Freund , "Shankaran, Akash" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <20240404171828.GA3866970@nathanxps13> References: <20240401011708.GA2128739@nathanxps13> <202404011106.y4fci35kzdqt@alvherre.pgsql> <20240401155338.GA2296072@nathanxps13> <20240401213140.GA2362108@nathanxps13> <20240403225029.GA3851411@nathanxps13> 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, Apr 04, 2024 at 04:28:58PM +1300, David Rowley wrote: > On Thu, 4 Apr 2024 at 11:50, Nathan Bossart wrote: >> If we can verify this approach won't cause segfaults and can stomach the >> regression between 8 and 16 bytes, I'd happily pivot to this approach so >> that we can avoid the function call dance that I have in v25. > > If we're worried about regressions with some narrow range of byte > values, wouldn't it make more sense to compare that to cc4826dd5~1 at > the latest rather than to some version that's already probably faster > than PG16? Good point. When compared with REL_16_STABLE, Ants's idea still wins: bytes v25 v25+ants REL_16_STABLE 2 1108.205 1033.132 2039.342 4 1311.227 1289.373 3207.217 8 1927.954 2360.113 3200.238 16 2281.091 2365.408 4457.769 32 3856.992 2390.688 6206.689 64 3648.72 3242.498 9619.403 128 4108.549 3607.148 17912.081 256 4910.076 4496.852 33591.385 As before, with 2 and 4 bytes, HEAD is using the inlined approach, but REL_16_STABLE is doing a function call. For 8 bytes, REL_16_STABLE is doing a function call as well as a call to a function pointer. At 16 bytes, it's doing a function call and two calls to a function pointer. With Ant's approach, both 8 and 16 bytes require a single call to a function pointer, and of course we are using the AVX-512 implementation for both. I think this is sufficient to justify switching approaches. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com