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 1s2CJm-000qPh-06 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 May 2024 15:56:26 +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 1s2CJi-00DLWO-NX for pgsql-hackers@arkaria.postgresql.org; Wed, 01 May 2024 15:56:23 +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 1s2CJh-00DLWG-PC for pgsql-hackers@lists.postgresql.org; Wed, 01 May 2024 15:56:23 +0000 Received: from mgamail.intel.com ([198.175.65.20]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s2CJa-000xAj-3S for pgsql-hackers@lists.postgresql.org; Wed, 01 May 2024 15:56:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714578974; x=1746114974; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=CgFyAZd8j7AspmhgaZu3MMoXyHqJ/oxEq9zF5YBTPPo=; b=JgVbn4oBIIPFP4T+mEb9/9cGGiai6RMmyROCD1mGqOpVAE08pMCcFLyd iOyDG2hov8ST4pH/9UtL1XoabtCcJcooJj1cexBOaJsCyrZzim7nQQpol 4xYThT1pwdQlxGerHbA5bSJzFP1luBnG1k3CoMq6Nnzc5jEUnON/WbKBG TtYJKcNZ+qHV9wzG+S02CvwEi+6513huUDzCR0LqNDNyu+XZop0hkE+lS NOqM03Hx8Q1gx+zW5VHW2YeHCmfX4ChltrBbJkC2YVEXkDZOz8eaVwHoR 7B9vlNfRKUHMtG6SChKfTD1nFcVByF3RywBcIYo40hEfD96J2jTttLluJ w==; X-CSE-ConnectionGUID: kj0Ay8mbTTGkbrkD8mLLtw== X-CSE-MsgGUID: j6RymYzsSPaAPTjpy1/pZg== X-IronPort-AV: E=McAfee;i="6600,9927,11061"; a="10140133" X-IronPort-AV: E=Sophos;i="6.07,245,1708416000"; d="scan'208";a="10140133" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2024 08:56:12 -0700 X-CSE-ConnectionGUID: U2oLo6MpQySJKoEr3tKl2Q== X-CSE-MsgGUID: 8YQYwW+MTFGfBR/Irayq7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,245,1708416000"; d="scan'208";a="26775600" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa009.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 May 2024 08:56:11 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 1 May 2024 08:56:11 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 1 May 2024 08:56:11 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 1 May 2024 08:56:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fzJtsnDKK1HkYNa5JkB2szfIlcwcnV0dyS4IDxs0UfHYXxvB8+ehcOJiIux7wn2KWlVj5g2qWsjvlw6ivrwkeWX/OZgKufCM5Oa5zjhWx9aqRl490CZI5oHj58oqPxLZNCLo2S22DAtDMnEDuyLZ4MGdJ4f/arJcPZKKn8uTPUZwb/XEXKQsBp0EVYzg0BoQxmYCj0D5U4XUz6Rb+Pbu6Auskmnx1KDSV0Fl92RGQEFLeluwFw93ABYxlRNETYe6ED2Yij0Mff0i7gOuKRuRrwMdDetfZ/PLPBQDwsJ0GxDokVgKiIn32g158KgJ0VFXvP+cpXTbVb4JcH1zKsYg4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/pZKjltAC1C0zn0uB8u8ZXgm9S9oe2CiMuyW6QEnGS0=; b=Lgz1V3OBsZv1D/w+uwt/gMkTDPGv8e1P6zA2kFTEZLPBDoGR8/8yGoXyBsel0Q+OSf2thLHM5nCWDn+U65wg+wZH75O1t71vuV/BkHAYucU1zqcdw55BvVitgizK4fWsH4mEF+bzY0qwuok0XOLIHlA77fXclN/rv+MU1CI7Ib5vy4xv54YqLgxJD4hOb2yY9seV7/LNTFWBKll3HE9v5tCJi98pJaF2NEMybnvScoIPUncDYgqyYT7d41AnFeJXa/7UoQtVobx5yo9ZYF5pj0MM/gQIzly9/kX2+1CM7tj+5qE5i4QgOykw1tXGqPyBJRYr4uqe4VPnPxIYoawHTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BL1PR11MB5304.namprd11.prod.outlook.com (2603:10b6:208:316::20) by IA1PR11MB7680.namprd11.prod.outlook.com (2603:10b6:208:3fb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Wed, 1 May 2024 15:56:09 +0000 Received: from BL1PR11MB5304.namprd11.prod.outlook.com ([fe80::c3d7:736f:7cf2:4d0f]) by BL1PR11MB5304.namprd11.prod.outlook.com ([fe80::c3d7:736f:7cf2:4d0f%4]) with mapi id 15.20.7519.031; Wed, 1 May 2024 15:56:09 +0000 From: "Amonson, Paul D" To: "pgsql-hackers@lists.postgresql.org" CC: Nathan Bossart , "Shankaran, Akash" Subject: Proposal for Updating CRC32C with AVX-512 Algorithm. Thread-Topic: Proposal for Updating CRC32C with AVX-512 Algorithm. Thread-Index: Adqb27jiuXmC5sH1QzmzETmUIqng2A== Date: Wed, 1 May 2024 15:56:08 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BL1PR11MB5304:EE_|IA1PR11MB7680:EE_ x-ms-office365-filtering-correlation-id: ac2a3eb5-c8e0-4c51-7bc6-08dc69f73799 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230031|1800799015|376005|366007|38070700009|3613699003; x-microsoft-antispam-message-info: =?us-ascii?Q?NmjNgvjNUXuMr9u7FcQ6TWblzPRcurwyTfynMJTd99LZtpTBLZCKMI7vcHtX?= =?us-ascii?Q?JwAN1IukB7GMQ7q//vu96W0+6tfYfxm2Y2DMLeHsifO0j+7DNfYF3JCNW/Gi?= =?us-ascii?Q?sazx3VxHfgm2sAeaxgiEO/CxFiBmc+VLh9lj8csghpFQjNwSsa9n+flGch9T?= =?us-ascii?Q?m+qpXptH7/IMm9nBt3fCrNJjm/LBFypZGRTddIOxNSyvJdmfDGp2JytC2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jDA0FRO36wtZqps0z3zNE+oxPaGm7P7IjyL6VJoOqylR?= =?us-ascii?Q?8CE4g4lHykeX27AMPmVV21x1FzOgcDUSELtjj9qroUPZD7jIqsU6rZuMaOC7?= =?us-ascii?Q?zN33ET07wqPpwC39H+5BRpNx7doQH7t3Sam4LQVFLHj24zhP7UT7giftPifc?= =?us-ascii?Q?LZ9waIJu/9Y8o6ztqjnjthmPaEGhJk1mNNWomBQHj6+GGydYSfZiaCMiNRlW?= =?us-ascii?Q?rDMv+WPQSZfPP5Vo3xd+zoVU?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR11MB5304.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(366007)(38070700009)(3613699003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BJhq+2IV1FBH+lqLLZx+zS5LzvikLMDVRTzpuQ7YoS1SGoQZVa3NvxfEGTvv?= =?us-ascii?Q?VFY/ulKKg5GzbXAL+6CvkO6LAbmdruzrWe+1IHRiZDyekYw+bN4oPiucHScc?= =?us-ascii?Q?QzA3bhZmniOqeQw2AKlwuwKf8En1xCPDxq3JjyAwlsFXXvWwDYrkspd3LIPX?= =?us-ascii?Q?q013Ngf70fx7jmkfGDi+gXIOxQGUCZbkoKzVrnNyZgj+0BzGDHRxLSmwjcc6?= =?us-ascii?Q?f22cg177UsQNDflbasxl10c2EXrw0zTC5reMRNXUEfWYWzIYKLcr9diF3aOn?= =?us-ascii?Q?rGRwHYa9cT5fpmv0cUH5Iu7DFSn7hxGdMr3x+jAykTqsAsM7KUAX22RfFOIH?= =?us-ascii?Q?YstQXUmHXcgD7BZzFxRDPwBJVB5J2UwhO8pHrEnRyylonmoMEqs0tiNGWUuK?= =?us-ascii?Q?IBYiJm/UzeESydAr702aoYyGZoldUw6efx9Se8S8jKa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b/CVI1Dw76GTCi3zFrSy7Xn67jLp2/qU8grEFYeefLJ1i4OWZKojRIfdmM4I?= =?us-ascii?Q?MncUURxwr9UlraBTfxud0/dzV0/LMkdE12meBC1O6vT5w22TpdEGtOKZ6rP7?= =?us-ascii?Q?W0ACRAA/yO9iRFN4gzM301p+fi+Qm6N61h2u8zf6bdZ8fvQM2Kng5DUQDRHU?= =?us-ascii?Q?iYt+StMd9wo92n2EfY2J9o7Dbcsn5bwB7RjFJoZia0sIDgYUj1S0VwFXgLf/?= =?us-ascii?Q?urES4v1WiKTZ9bwe9qLYO8p676tixMQCUicThuE/?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5304.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac2a3eb5-c8e0-4c51-7bc6-08dc69f73799 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 May 2024 15:56:09.0154 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LYtO87srJqh0vsirVaOLILRT3REyDVqi5qyKthlfZWspg8/mvJnDrnSYMSUFCpxyIPgz6mQQw7q4+BBUyRRcMs4HoYDvCN1SDY4iaX7ua4Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB7680 X-OriginatorOrg: intel.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Comparing the current SSE4.2 implementation of the CRC32C algorithm in Post= gres, to an optimized AVX-512 algorithm [0] we observed significant gains. = The result was a ~6.6X average multiplier of increased performance measured= on 3 different Intel products. Details below. The AVX-512 algorithm in C i= s a port of the ISA-L library [1] assembler code. Workload call size distribution details (write heavy): * Average was approximately around 1,010 bytes per call * ~80% of the calls were under 256 bytes * ~20% of the calls were greater than or equal to 256 bytes up to the ma= x buffer size of 8192 The 256 bytes is important because if the buffer is smaller, it makes sense= fallback to the existing implementation. This is because the AVX-512 algor= ithm needs a minimum of 256 bytes to operate. Using the above workload data distribution,=20 at 0% calls < 256 bytes, a 841% improvement on average for crc32c functi= onality was observed. at 50% calls < 256 bytes, a 758% improvement on average for crc32c functi= onality was observed. at 90% calls < 256 bytes, a 44% improvement on average for crc32c functio= nality was observed.=20 at 97.6% calls < 256 bytes, the workload's crc32c performance breaks-even. at 100% calls < 256 bytes, a 14% regression is seen when using AVX-512 imp= lementation.=20 The results above are averages over 3 machines, and were measured on: Intel= Saphire Rapids bare metal, and using EC2 on AWS cloud: Intel Saphire Rapid= s (m7i.2xlarge) and Intel Ice Lake (m6i.2xlarge). Summary Data (Saphire Rapids bare metal, AWS m7i-2xl, and AWS m6i-2xl): +---------------------+-------------------+-------------------+------------= -------+--------------------+ | Rates in Bytes/us | Bare Metal | AWS m6i-2xl | AWS m7i-2= xl | | | (Larger is Better) +---------+---------+---------+---------+---------+--= -------+ Overall Multiplier | | | SSE 4.2 | AVX-512 | SSE 4.2 | AVX-512 | SSE 4.2 | A= VX-512 | | +---------------------+---------+---------+---------+---------+---------+--= -------+--------------------+ | Numbers 256-8192 | 12,046 | 83,196 | 7,471 | 39,965 | 11,867 | = 84,589 | 6.62 | +---------------------+---------+---------+---------+---------+---------+--= -------+--------------------+ | Numbers 64 - 255 | 16,865 | 15,909 | 9,209 | 7,363 | 12,496 | = 10,046 | 0.86 | +---------------------+---------+---------+---------+---------+---------+--= -------+--------------------+ | Weighted Multiplier = [*] | 1.44 | +----------------------= -------+--------------------+ There was no evidence of AVX-512 frequency throttling from perf data, which= stayed steady during the test. Feedback on this proposed improvement is appreciated. Some questions:=20 1) This AVX-512 ISA-L derived code uses BSD-3 license [2]. Is this compatib= le with the PostgreSQL License [3]? They both appear to be very permissive = licenses, but I am not an expert on licenses.=20 2) Is there a preferred benchmark I should run to test this change?=20 If licensing is a non-issue, I can post the initial patch along with my Pos= tgres benchmark function patch for further review. Thanks, Paul [0] https://www.researchgate.net/publication/263424619_Fast_CRC_computation= #full-text [1] https://github.com/intel/isa-l [2] https://opensource.org/license/bsd-3-clause [3] https://opensource.org/license/postgresql =20 [*] Weights used were 90% of requests less than 256 bytes, 10% greater than= or equal to 256 bytes.