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 1tzeQd-004ltt-6L for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 16:25:31 +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 1tzeQa-004DfX-HJ for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 16:25:28 +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.94.2) (envelope-from ) id 1tzeQa-004DfP-3j for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 16:25:28 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tzeQY-002NDW-17 for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 16:25:27 +0000 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e643f235a34so4360696276.1 for ; Tue, 01 Apr 2025 09:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743524725; x=1744129525; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=74RuOxG+WmpUL5X1Q+LtqcvLEVlIOPFGdyvHY8XQ4i8=; b=d06yIsVG8naXxXzDYXigjMrbTtvAXI6IIZq2uYO98qTJCU0nIixHaH6T00YS4FHeoH EX329y1NGNOFS/cLVruyVfoUItjjOpb9tWgfAhm7eTqphDtNDV8d+yZImkQ2A20c4Wpz y4YXAJKiSp4gouWpM/IAALSJij/i+Zj8k1By69utWSoDTIhPb2BzEAYlGFJ5ndf+dzOR RmIp7JkBU3jpNysdk5fcW2Z7BDOccKUHTDW66kgq/4sOjtk57oOpFsLEdREWi8CH0knj iI/uMSf9IrCXw3/bUuDzQknLY+EKRu4V5EmrdxpvNA9zR20I6t5cQwJBGc6XhWVmvFyE IHPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743524725; x=1744129525; h=in-reply-to:content-transfer-encoding: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=74RuOxG+WmpUL5X1Q+LtqcvLEVlIOPFGdyvHY8XQ4i8=; b=ddKSYtlNtk50LVIXUC5ZRHCFAkH47BIkpOKxnAjYSo4uCDvl7SnOSNhrF3dZWj+pSD xG14K7Y6C+BaZDDHVgJOtmOvL1tSMgT25HwDr42JLw9qg5KojaERP7qvPvSC5DfMFKsD JlFWWjgloH105F9wztQHWLjaoqE0viM7mvzaXyEelkt3qxrGNDGcnkp9N66U41mbTOt6 ql8IGMOlemaSOOKIjAZZe0sVmZpYW/R+zzD5k2WdZNbhJgUtFRgj9JXEgaSw+9rE4f+0 GAfah962Y9wQK/C8WQqLac/1dzvavmVM/7Mj4q1U6o9b/4rW4inFJByVqqC1caIUL6ZP T61g== X-Forwarded-Encrypted: i=1; AJvYcCW6VuZ4Oxn6RrRb9vBd3SYcMmuGS0kM9hQem41YNWFf6UXojwFBCPJVo9s2lLYoHNCWojL0/dsQaOy2qpS5@lists.postgresql.org X-Gm-Message-State: AOJu0Ywb9VYoRQavdr9nEey0pysVE9m8owetwf5Ohs2r/1kTS+rXo8Fp 6CaJov2Y7pk6PnbGPEipuQgUz09BNJRkTB4gOunQG3b2N+GkA4s8 X-Gm-Gg: ASbGncvbW3LP8Rbt/LnWr051cfRp7Sp9RJr0D/OJ/vZHX4JMI3cgCFT/azPFgGIBVzi agP0vqJ4CMHYptjkyP2o2sBSZfxMCAbun9WOnAv5f1bX/TspOZlIWVTLvYmmpsT1hq+pQqdXS3r ulJ1tUkyz/m8U62Aj338E4tUw+NrvkxSvICqx4h2GFnv5Vxmetd2j4sozRBeVEbO3CYgUXeRCHb fGaLNoPXh2QI4khlLUf33d4C10xfUiyLLsbqSraKu/jfaQCXxBKBFiXHU6dhuVbH/AVMSDwFwBW IGmtdiB6uFVn+2f1+O0hPQwu2sM/kmVC31WchyH2s6PNeSxJQLf3pjWsKdO8J+PstXzjM9QTkHE bMden1bke7HVCIRZFOYVh+u0UR+PVf6zWp3Q= X-Google-Smtp-Source: AGHT+IEzU6WYAGtrJ9AxpzePHng2zDQsNJWdZ1a/rWsvapUD+kem484xL3g/ZnJIwvjKWvEfkcp4vQ== X-Received: by 2002:a05:6902:e06:b0:e6d:e367:24e9 with SMTP id 3f1490d57ef6-e6de36725a6mr2860267276.30.1743524725449; Tue, 01 Apr 2025 09:25:25 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e6b97e23fddsm1414835276.31.2025.04.01.09.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 09:25:24 -0700 (PDT) Date: Tue, 1 Apr 2025 11:25:23 -0500 From: Nathan Bossart To: John Naylor Cc: "Devulapalli, Raghuveer" , "pgsql-hackers@lists.postgresql.org" , "Shankaran, Akash" Subject: Re: Improve CRC32C performance on SSE4.2 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 01, 2025 at 05:33:02PM +0700, John Naylor wrote: > On Thu, Mar 27, 2025 at 2:55 AM Devulapalli, Raghuveer wrote: >> (1) zmm_regs_available() in pg_crc32c_sse42_choose.c is a duplicate of >> pg_popcount_avx512.c but perhaps that’s fine for now. I will propose a >> consolidated SIMD runtime check in a follow up patch. > > Yeah, I was thinking a small amount of duplication is tolerable. +1. This is easy enough to change in the future if/when we add some sort of centralized CPU feature detection. >> (2) Might be apt to rename pg_crc32c_sse42*.c to pg_crc32c_x86*.c since >> they contain both sse42 and avx512 versions. > > The name is now not quite accurate, but it's not exactly misleading > either. I'm leaning towards keeping it the same, so for now I've just > updated the header comment. I'm not too worried about this one either. FWIW I'm likely going to look into moving all the x86_64 popcount stuff into pg_popcount_avx512.c and renaming it to pg_popcount_x86_64.c for v19. This would parallel pg_popcount_aarch64.c a bit better, and a file per architecture seems like a logical way to neatly organize things. > For v16, I made another pass through made some more mostly superficial > adjustments: > - copied rewritten Meson comment to configure.ac > - added some more #include guards out of paranoia > - added tests with longer lengths that exercise the new paths > - adjusted configure / meson messages for consistency > - changed not-quite-accurate wording about "AVX-512 CRC instructions" > - used "PCLMUL" only when talking about specific intrinsics and prefer > "AVX-512" elsewhere, to head off potential future confusion with Arm > PMULL. I read through the code a couple of times and nothing stood out to me. -- nathan