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 1t8krM-005nl1-Ii for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2024 18:34:27 +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 1t8krJ-008F79-Uh for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2024 18:34:26 +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 1t8krJ-008F71-LA for pgsql-hackers@lists.postgresql.org; Wed, 06 Nov 2024 18:34:26 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8krH-000Vk9-Ah for pgsql-hackers@lists.postgresql.org; Wed, 06 Nov 2024 18:34:24 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1283C254019C; Wed, 6 Nov 2024 13:34:22 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 06 Nov 2024 13:34:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding: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=fm2; t=1730918061; x=1731004461; bh=iH9F/cPLdSgvSJnmSiVBfoMt0EOhwD2y 1c+P26PTyz4=; b=mX9o9Z2Ll2FdaErlSbvAplwTWCXD2TMhSrnTow4Tl8Z+G9aK PLLJNuBxMwJZSHaI/GpdTPFfN23ab5VXfmhJ921On59cMxwDsSjJtuzCZpjOwoLC YwbN1o9ABm1u9M4mT2LsIIpl1lLY5fXnRNvCjofkRZ2aueLM5xiVp6u/SZ10LXB4 IUwHn8asyZNjkG9qJoA+BYzUnEDcQUlAzHCoWtzH/o9CrvGADkeL4ZDlUaWzYQec yR4Xj3fgyVfWD6W5w7Qa0ig+EOqMAkXwFVioC53AgUZuZSAOmJyW15p3LXtI5JYS CoGELTyHsFmevwMr1T3hzf1c5Ty0hTjQL54lwg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1730918061; x= 1731004461; bh=iH9F/cPLdSgvSJnmSiVBfoMt0EOhwD2y1c+P26PTyz4=; b=k JL1mfYDnu2vcb8bykMPXbWcvnj0hgSjR0S7m3CwIqcvo9pvCZID06ADgUJNQCBzD TqBMtUma2xQkX3TLJwhUwlZ8peZQs8TKfP/sngeCwzzMVexYmfBcFqaCzusayYN7 mrl2Dv5FkscKM6YWl5FW84768jApeAdaTM0qgw6M47bnw0zq0ScdV5pwUqkTzjbJ qJMwkS9sbkvMnDBZb+PhPx6Y2wZczhEco5lxXxgZWYCDLrRDUukipYBCgBWoII5+ SkdC9RwSxiyZUGxtnCGTk3DOcf47qRnjqt0Uc7DHkCTCP4U1DiOWxYdUtj3AFYN6 f0oM5tEfoSa0HHJ/UweVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrtddvgdduuddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdej necuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvg hnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhepgfejtdfhkeeftdeugfeileeh teeljeeghfeuledthfeutedvffdukeefjefhgeehnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdho rhhgpdhnsggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhope gsvghrthhrrghnuggurhhouhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthho pegughhrohiflhgvhihmlhesghhmrghilhdrtghomhdprhgtphhtthhopehrrghnihgvrh drvhhfsehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhhitghhrggvlhesphgrqhhuihgv rhdrgiihiidprhgtphhtthhopehsmhhithhhphgsvddvhedtsehgmhgrihhlrdgtohhmpd hrtghpthhtohephhhlihhnnhgrkhgrsehikhhirdhfihdprhgtphhtthhopehpghhsqhhl qdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Nov 2024 13:34:19 -0500 (EST) Message-ID: <0ead6139-707f-4a21-b1df-afdd7ae5d1a6@eisentraut.org> Date: Wed, 6 Nov 2024 19:34:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: define pg_structiszero(addr, s, r) To: Bertrand Drouvot , David Rowley Cc: Ranier Vilela , Michael Paquier , Peter Smith , Heikki Linnakangas , pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 05.11.24 16:03, Bertrand Drouvot wrote: > On Tue, Nov 05, 2024 at 05:08:41PM +1300, David Rowley wrote: >> On Tue, 5 Nov 2024 at 06:39, Ranier Vilela wrote: >>> I think we can add a small optimization to this last patch [1]. >> >> I think if you want to make it faster, you could partially unroll the >> inner-most loop, like: >> >> // size_t * 4 >> for (; p < aligned_end - (sizeof(size_t) * 3); p += sizeof(size_t) * 4) >> { >> if (((size_t *) p)[0] != 0 | ((size_t *) p)[1] != 0 | ((size_t *) >> p)[2] != 0 | ((size_t *) p)[3] != 0) >> return false; >> } > > Another option could be to use SIMD instructions to check multiple bytes > is zero in a single operation. Maybe just an idea to keep in mind and experiment > if we feel the need later on. Speaking of which, couldn't you just use pg_popcount(ptr, len) == 0 ?