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 1sBLnK-00G1G9-I9 for pgsql-hackers@arkaria.postgresql.org; Sun, 26 May 2024 21:52:48 +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 1sBLnK-004uCD-IK for pgsql-hackers@arkaria.postgresql.org; Sun, 26 May 2024 21:52:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sBLnI-004uC5-Og for pgsql-hackers@lists.postgresql.org; Sun, 26 May 2024 21:52:46 +0000 Received: from wfout4-smtp.messagingengine.com ([64.147.123.147]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sBLnD-000uoe-TV for pgsql-hackers@lists.postgresql.org; Sun, 26 May 2024 21:52:44 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id 699ED1C000A9; Sun, 26 May 2024 17:52:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 26 May 2024 17:52:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=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=fm3; t=1716760356; x=1716846756; bh=4jaCrl0ipGM0uGUJhxrEcobB+b4fkGRtMcsjtY59QaM=; b= CuMmGK1pHmOYy33MLzajEvPcc5Loj11gth9vBsAW7H+qS5m5z+mtcDwP05Jn/M9I lW9lB/eekoUBIrUhdQYctCGf0t4lgWLdY2DAXYfALYMchRTvNqlbGqV6Kr/qQwkA bN+t1P1J5eEHoCiVloIyVoRUdqWwifjlj3zlkr6VyyhPescrOBdvfbtkNAFizViI g6sGo5Ad5Z4KEfRNoM/R2nkW1tob4TrTwlhvF/1yeHljKL3cyJSKL7XxkUSwVqZM ILw+CLmfbBelS7QVxzuNt46D0MQQA9zz9MHDCfeT5lRlrnA/5qixTF1nBou0XmFz mmLW5HYYP8LdyQqvajj1uA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716760356; x= 1716846756; bh=4jaCrl0ipGM0uGUJhxrEcobB+b4fkGRtMcsjtY59QaM=; b=P m+5PScOwXHZDSY9KwF+0/1OAK3RXZXfsEdIcR3VewpnSyVYV/oRj2n5Z1BxE9ldQ J/rHeb5KxdsoApoWobwzBieooxWX18LUDol/apQHse5yOw78+YcnHVHT3rJX0ZKx 3FlvvBlwjguyYRExiI8xy6iVJHBiK5UCls3eg5n9/ATTN1XjCsovGUwCdvGpyBl5 D+h88AoO8P2uBDPBdmbqNjRoJFU3ZPzYGuPqPnlISCtINhP3Mfm6cEK4wPUZHBHD vBPZ2dtkyvxFbKH+QHf+rnbudA9L2Z/Fp+daH9OcJH0oVfwvaBxEoTFa5skBMm7s 9PIS8lkEDtQgIY9ham3WQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdejfedgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqe enucggtffrrghtthgvrhhnpeehiedvhfeuhfeugefgfeehgeejtdevuefhtefhueefvddu gfdtueehgfefudfhffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 May 2024 17:52:35 -0400 (EDT) Message-ID: <84e2783f-8082-4fd9-bf5f-31982caf9aff@eisentraut.org> Date: Sun, 26 May 2024 23:52:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Improve conditional compilation for direct I/O alignment checks To: Junwang Zhao , PostgreSQL Hackers 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 26.05.24 09:16, Junwang Zhao wrote: > This patch refactors the alignment checks for direct I/O to preprocess phase, > thereby reducing some CPU cycles. This patch replaces for example if (PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ) Assert((uintptr_t) buffer == TYPEALIGN(PG_IO_ALIGN_SIZE, buffer)); with #if PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ Assert((uintptr_t) buffer == TYPEALIGN(PG_IO_ALIGN_SIZE, buffer)); #endif You appear to be assuming that this saves some CPU cycles. But this is not the case. The compiler will remove the unused code in the first case because all the constants in the if expression are known at compile-time.