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 1tk57M-00HJvH-Vm for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Feb 2025 17:41:16 +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 1tk57L-000qyD-OL for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Feb 2025 17:41:15 +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 1tk57L-000qy0-Di for pgsql-hackers@lists.postgresql.org; Mon, 17 Feb 2025 17:41:15 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tk57J-001MSQ-0S for pgsql-hackers@lists.postgresql.org; Mon, 17 Feb 2025 17:41:14 +0000 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-8559020a76aso28706439f.2 for ; Mon, 17 Feb 2025 09:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739814072; x=1740418872; 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=qgt3UMW1xgnYVj3NBU0bF2Jqd+WYnSufupfH5n3KFVU=; b=mfrjRk1D//DXeqLVg/s6LwEk+mpTpYb+MjBbjsPZh4y4PrtgJms0/PbxWo2HvR/uGC 8/wa6DR8OhlSG/eGWtqq1UelOgbmMAjhQIGYAV1Zfs8L4IFH/TdzWynsSPMHkWvZ5xzu /4wzwOIGlejD1Wc9JyXVfrKGrhhJc6yKTXTWBLFzsIBbsURg3km/wYbE38c6VgU8fQWE bTjUHnQxUEnyD0eKZAmkr+Vt350Ata61qXWm/0zlsC+Le7Yb+VjV7BsSPGC1/vO8pstS ItiENb1489ni01dtEbQ1pUAdld4V3uDav4lbomxTv2GrW77dbYvseDIMEtiW+cf3R6sn b1rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739814072; x=1740418872; 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=qgt3UMW1xgnYVj3NBU0bF2Jqd+WYnSufupfH5n3KFVU=; b=MN6u8k7jY89GQkQsvZ20y8umWv+d81Bf5b3w8Pult4pmwmLHx7dmATImmddKT76M+T wPc+5lZcKE/YHEzh/Q1Ow0Gt5YCHu1np03IInWFHK57bLjZL2Rs0J63ktNb8yEpmY5ro E7lFKG5+0tvkFPKnGKsUS9pSVg3yY9AtmY7ARpWo68ibwHIIDmzBzQ2fRMMOhN+cuvs+ +IvwaGIJ8MErjp/DZtL8mimniJ7u+j/koRQP4oUXKhiAFBc8XVoWNXgZpmudRtlRpWwH GOmNXMmUMXJvNNUVyz7J9fKh/33BQoxArQgtTi0EVEGGi2ocpqDDyGm5ILUZwf9Tgq3P CP2g== X-Forwarded-Encrypted: i=1; AJvYcCWvysBHjYKnewpYw4oOef0XgnMlg7Z9qCV4GPN6/ay6yXjFsjZs2Q2vwr6WT9kw4cvtVrLiK8QsfV0fuJbg@lists.postgresql.org X-Gm-Message-State: AOJu0Yy8itXbe+4NpRSJxu+8Orur45o7EXdywnNuaU8wH8KsK6c4NQcd XOZgEL7/fqfTwTWQM2nmkRTL8Xs5T1Oe5MrR2HVMEc4tuZpc/UtJ X-Gm-Gg: ASbGncvgYqC7z4kbSRehGuoj90nqQS6jhezv9Z6FsA75/LJ39GiXN0ZwCczRlaSya9G mBhOQwIIM4LhwuBOB7FwMH970GVhwNI/LgWsAtrN3wr4UqXitsIcBWDLg3wS7jOom2u1Ep7s/Ei UfzEbFY5bZ9E8WUbMHFe5EvcTP76yXIWTCgg5ouXE1iiBUOG1SOmtg7Yaj538nh0Iw4+dTXKG4I 5zN9ee5pQIdXRo/rh2/2OoQ4y+8TEYZcklP9cO2+ajr6Vp15v1vHXznWkRcQwyXi20KGXLed58b wc6pZYQNBrTjLywZInfE/3t0oBlFLrCZ/ud+YslouJZU4DA5enJRPN4EfsCfHuFZY0ka/w4nNJY YU/ZhyA== X-Google-Smtp-Source: AGHT+IHJl+d/ku8DHJiLYcAdoxf5Mz2Pbs4ACQBBFtibmTvSTmDbEbtnJHibOh62PUhh4xwK6E0w/g== X-Received: by 2002:a05:6602:6d82:b0:855:432b:5d35 with SMTP id ca18e2360f4ac-8557a1546d3mr957093439f.12.1739814072433; Mon, 17 Feb 2025 09:41:12 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-85566e6243dsm201903339f.23.2025.02.17.09.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 09:41:11 -0800 (PST) Date: Mon, 17 Feb 2025 11:41:09 -0600 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=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 Mon, Feb 17, 2025 at 05:58:01PM +0700, John Naylor wrote: > I tried using branching for the runtime check, and this looks like the > way to go: > - Existing -msse4.2 builders will still call directly, but inside the > function there is a length check and only for long input will it do a > runtime check for pclmul. > - This smooths the way for -msse4.2 (and the equivalent on Arm) to > inline calls with short constant input (e.g. WAL insert lock), > although I've not done that here. > - This can be a simple starting point for consolidating runtime > checks, as was proposed for popcount in the AVX-512 CRC thread, but > with branching my model was Andres' sketch here: > > https://www.postgresql.org/message-id/20240731023918.ixsfbeuub6e76one%40awork3.anarazel.de Oh, nifty. IIUC this should help avoid quite a bit of overhead even before adding the PCLMUL stuff since it removes the function pointers for the runtime-check builds. While this needn't block this patch set, I do find the dispatch code to be pretty complicated. Maybe we can improve that in the future by using macros to auto-generate much of it. My concern here is less about this particular patch set and more about the long term maintainability as we add more and more stuff like it, each with its own tangled web of build and dispatch rules. -- nathan