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 1t8AvV-002Vf1-6f for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Nov 2024 04:12: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 1t8AvS-008ca2-Lz for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Nov 2024 04:12:19 +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 1t8AvR-008cYP-RW for pgsql-hackers@lists.postgresql.org; Tue, 05 Nov 2024 04:12:18 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8AvP-000EzX-L1 for pgsql-hackers@lists.postgresql.org; Tue, 05 Nov 2024 04:12:17 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6011511401F6; Mon, 4 Nov 2024 23:12:14 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Mon, 04 Nov 2024 23:12:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; 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=fm3; t=1730779934; x=1730866334; bh=SmCsldiayY 73zQ7FEWWaK1wpzv9/vckCy5nxTfy/wy8=; b=QGOgGPxnGShEkACKzzzMR5aOIa 9asQThs2ut+Oq+jLAaDgEnc+2WFC+n/Y2yxUdcndjKPa4Th0cwuy+/o/gChAZg8a 40PR1Idkl+jhN85UymrgMgicanzwkL59r/O26DJeGUi+mY6kOOy5IjNV2B/3+fA3 SOcDqmu5QOuO+LISdqNlXfSS8C08K3oP0M0Fb5Y+NglQ6jw8+/gTeWSglJju+q79 IOZw8c7aYhfG/4b9VYLCvfUoJpKk2VwAdlLahpS/745N1i2bo2GX6ioW91/XnebY Pi+Qyx+2q1z3oRnp/JQbMmTliTrCiXhb+ss+0pze5yg3V7FGYBpbsHg4xNIw== 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-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1730779934; x=1730866334; bh=SmCsldiayY73zQ7FEWWaK1wpzv9/vckCy5n xTfy/wy8=; b=hpzxuxPVXspEmnQGutiuJSuSKjEN8nz91o+QJ/kOQGs96t5AT52 cxRA9o++JAs7iPJcrLMv6gYiGIFpeA3xzoyfeuh58tf+hYabYeqNxykJoZAltVlc QnrR3sB/+Curus71/eECbbnoqn8zhdbI5atO9WRyZiAzDxozXoWyrXsC5jmkjCST +I7IFjCQ6HDgg26HrgNNDtktqZnSV1vTktwVxXfgN/T8SE1LQyJZk7PHo6DW5QIv k3C6ShX2M3caIS6iAia56D+Ri3aGHHcwfYHAy1x8obhkKhH7Jhb4lbCdH9JArZ4r 52Q3amClH2CxThFu0AuKPRgvWaITme9ZE/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdeljedgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhf gggtuggjsehgtdorredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruc eomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepffdu leehgefhkeefgfeftdfhkedutddvhfdukeeggeehieekffelhfelkeehteefnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhes phgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepjedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepughgrhhofihlvgihmhhlsehgmhgrihhlrdgtohhmpdhrtghpthht oheprhgrnhhivghrrdhvfhesghhmrghilhdrtghomhdprhgtphhtthhopegsvghrthhrrg hnuggurhhouhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehsmhhithhh phgsvddvhedtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphgvthgvrhesvghishgvnh htrhgruhhtrdhorhhgpdhrtghpthhtohephhhlihhnnhgrkhgrsehikhhirdhfihdprhgt phhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlh drohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 4 Nov 2024 23:12:11 -0500 (EST) Date: Tue, 5 Nov 2024 13:12:03 +0900 From: Michael Paquier To: David Rowley Cc: Ranier Vilela , Bertrand Drouvot , Peter Smith , Peter Eisentraut , Heikki Linnakangas , pgsql-hackers@lists.postgresql.org Subject: Re: define pg_structiszero(addr, s, r) Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qHAFS1x9gwmjSSr9" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --qHAFS1x9gwmjSSr9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 05, 2024 at 04:23:34PM +1300, David Rowley wrote: > I tried your optimisation in the attached allzeros.c and here are my resu= lts: >=20 > # My version > $ gcc allzeros.c -O2 -o allzeros && for i in {1..3}; do ./allzeros; done > char: done in 1543600 nanoseconds > size_t: done in 196300 nanoseconds (7.86347 times faster than char) >=20 > # Ranier's optimization > $ gcc allzeros.c -O2 -D RANIERS_OPTIMIZATION -o allzeros && for i in > size_t: done in 531700 nanoseconds (3.6545 times faster than char) > char: done in 1957200 nanoseconds I am not seeing numbers as good as yours, but the winner is clear as well here: $ gcc allzeros.c -O2 -o allzeros && for i in {1..3}; do =2E/allzeros; done char: done in 6578995 nanoseconds size_t: done in 829916 nanoseconds (7.9273 times faster than char) char: done in 6581465 nanoseconds size_t: done in 829948 nanoseconds (7.92997 times faster than char) char: done in 6585748 nanoseconds size_t: done in 834929 nanoseconds (7.88779 times faster than char) $ gcc allzeros.c -O2 -D RANIERS_OPTIMIZATION -o allzeros && for i in {1..3}; do ./allzeros; done char: done in 6591803 nanoseconds size_t: done in 1236102 nanoseconds (5.33273 times faster than char) char: done in 6606219 nanoseconds size_t: done in 1235979 nanoseconds (5.34493 times faster than char) char: done in 6594413 nanoseconds size_t: done in 1238770 nanoseconds (5.32336 times faster than char) I'm surprised to see that assigning aligned_end at these two different locations has this much effect once the compiler optimizes the surroundings, but well. -- Michael --qHAFS1x9gwmjSSr9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmcpmxMACgkQnvQgOdby QH3/4xAAqiBw7qAR+YETFSPjpU7P7Ozm/qI0az/rklMk+ITMNw+ssrtGqxlOYDUR uPdoZIR0RpVn2v+1+aJOPSMSulym2nhmv5PfV/gidDGOJqNOkvP6oWuve6aOWxZf j1Nad5GlVYCSY8SuOrU9yp++brXr6PxttUbffDTImLPdbvxxIEBEsIyQlUQdfMhw 3Ie1tnYHiWIgp6IcCIErpaGXIyIjf+9EVz/4ubahVOHdyIegDiVMRHX6fI0Zfuz7 v+BXrWtfCMSebU3sVQR1aTmYmep2P3s4emrMJtrVeTJhhFf2a9vUghDrHnsGI3ud wFLoznmkkYo4GFOeRzHiSM4KA1yAs+Np5eyrl9h2e71ZAeHqDxdTtU+06QzN996O HmUin3eQPDjuG9qYhwq3+mJPc4oJxZOMZvareyaxirL2rgCQ+Q6oV0ft58c/vQcD uyGXk9gckMp92fW67NTQtkl92Sec2iAyU7R9gmPXFCOKAY7ATBL0IlJZGUsOUrJt jtgykWOEESErfBl6K6aDa6b+JBMTqDXRdyIYjSrryR9QghmJNaF1tqXOjGO6VE3L rvhuvdzcWnh4+Le1xBQ/lTOJsBUfntTHcEKqedBYqwZEqgYPiTDVulhajwZiaGFj /ocPVD8uGHmKq4BSDS4J9gIrcQhEGKkswHoRH0T/tu+sWA9462o= =FyeB -----END PGP SIGNATURE----- --qHAFS1x9gwmjSSr9--