From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Junwang Zhao <zhjwpku(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Improve conditional compilation for direct I/O alignment checks |
Date: | 2024-05-26 21:52:34 |
Message-ID: | 84e2783f-8082-4fd9-bf5f-31982caf9aff@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2024-05-26 23:39:46 | Re: Speed up JSON escape processing with SIMD plus other optimisations |
Previous Message | Daniel Gustafsson | 2024-05-26 21:27:25 | Re: DROP OWNED BY fails to clean out pg_init_privs grants |