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 1sOG5w-00DIcw-53 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 12:25:20 +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 1sOG5u-001I7l-8P for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 12:25:18 +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 1sOG5s-001I7c-KA for pgsql-hackers@lists.postgresql.org; Mon, 01 Jul 2024 12:25:18 +0000 Received: from wfout7-smtp.messagingengine.com ([64.147.123.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOG5p-0041nY-NF for pgsql-hackers@postgresql.org; Mon, 01 Jul 2024 12:25:15 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 9A9B41C00096; Mon, 1 Jul 2024 08:25:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 01 Jul 2024 08:25:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1719836711; x=1719923111; bh=ghAPOsgwZP +D9woZH4N6xCer+Eb5eOylS0gPu6SQo28=; b=WRUp6HzH6hmr4Q5SuwYeL66/VZ QuHFhrLDsK+AQRIrAubTX6PBMw94aAaLbcFu9tWoHr23BJSSA1dDFBFa66nHmRbi JFLQCBDBLJ2hHeCEc095w8v/UnGKZDkSFYphNORqcu3uUc1do8cV7QB3COTRQHke KP/8x3BDYDz/tSiaYQIOVEdkEczrG6LY3tFT8KL3PuMajfW+l68GwymAhKHMAoW1 /CnXSAYuEuzSRWRnyahgy/32XYukGLACESKVul2kZWJk02nI+iNkvSzEp/iyKu5Y w3Bs6w854MMqB5nGfjpro3zBQIRLxlyJW6e5k4J7WMUbVLczKOfoMr0kOw6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1719836711; x=1719923111; bh=ghAPOsgwZP+D9woZH4N6xCer+Eb5 eOylS0gPu6SQo28=; b=AOXM8TARPWsSH3YooS7hsTV/Fs/xeXJ7kgEMaUQoxe9k CVuKp9889xchwoU+BIz5jCumiRBmy4H4nFUMl+5Ki/E2G3VUJ9FhJ1WKcxTLZqKH h77vB5mp4WshejlUnsMSwPazCV7V1UKhxQ/NWeQXfvpJIlWEd9IqZssmH2/6ETnl p1MoAS4gqvYwkzIryYzlHbRUhn70wpzENeMT4fifhvHy7pVB4PRFxMvDPr/POShe 9uh+lCcJXXITUnAdEnCV7pDZi48KauTstFfOW3wUpKebLP5OIZ/34HGmlw1AwPTE nW8AYPk4xlLLeZ999KkP4h3Y4CnGUXxXoA7bpIdDqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudefgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufhfffgjkfgfgggtsehttdertddtreejnecuhfhrohhmpeffrghgfhhi nhhnucfklhhmrghrihcuofgrnhhnshonkhgvrhcuoehilhhmrghrihesihhlmhgrrhhird horhhgqeenucggtffrrghtthgvrhhnpeekleejueefhfffkefhkedtfeeluedvieeihfeh feeffeeggeduffduheejjeeigfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehilhhmrghrihesihhlmhgrrhhirdhorhhg X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Jul 2024 08:25:10 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: "Joel Jacobson" Cc: pgsql-hackers Subject: Re: Optimize numeric multiplication for one and two base-NBASE digit multiplicands. References: <44d2ffca-d560-4919-b85a-4d07060946aa@app.fastmail.com> Date: Mon, 01 Jul 2024 13:25:08 +0100 In-Reply-To: <44d2ffca-d560-4919-b85a-4d07060946aa@app.fastmail.com> (Joel Jacobson's message of "Mon, 01 Jul 2024 08:04:06 +0200") Message-ID: <87zfr1e1uj.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Joel Jacobson" writes: > Hello hackers, > > Attached patch introduces an optimization of mul_var() in numeric.c, > targeting cases where the multiplicands consist of only one or two > base-NBASE digits. Such small multiplicands can fit into an int64 and > thus be computed directly, resulting in a significant performance > improvement, between 26% - 34% benchmarked on Intel Core i9-14900K. > > This optimization is similar to commit d1b307eef2, that also targeted > one and two base-NBASE digit operands, but optimized div_var(). div_var() also has an optimisation for 3- and 4-digit operands under HAVE_INT128 (added in commit 0aa38db56bf), would that make sense in mul_var() too? > Regards, > Joel - ilmari