public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Eisentraut <[email protected]>
To: Junwang Zhao <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Re: Improve conditional compilation for direct I/O alignment checks
Date: Sun, 26 May 2024 23:52:34 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEG8a3J5w053U=O2+4_uxbXuMnmQFFVQef4GveV9QfW0wdeEaw@mail.gmail.com>
References: <CAEG8a3J5w053U=O2+4_uxbXuMnmQFFVQef4GveV9QfW0wdeEaw@mail.gmail.com>
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.
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Improve conditional compilation for direct I/O alignment checks
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox