public inbox for [email protected]
help / color / mirror / Atom feedFrom: Junwang Zhao <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Improve conditional compilation for direct I/O alignment checks
Date: Sun, 26 May 2024 15:16:19 +0800
Message-ID: <CAEG8a3J5w053U=O2+4_uxbXuMnmQFFVQef4GveV9QfW0wdeEaw@mail.gmail.com> (raw)
This patch refactors the alignment checks for direct I/O to preprocess phase,
thereby reducing some CPU cycles.
--
Regards
Junwang Zhao
Attachments:
[application/octet-stream] 0001-Improve-conditional-compilation-for-direct-I-O-align.patch (1.7K, ../CAEG8a3J5w053U=O2+4_uxbXuMnmQFFVQef4GveV9QfW0wdeEaw@mail.gmail.com/2-0001-Improve-conditional-compilation-for-direct-I-O-align.patch)
download | inline diff:
From 0d5b5264f0730c168b40934a1a721dc848fe0da0 Mon Sep 17 00:00:00 2001
From: Zhao Junwang <[email protected]>
Date: Sun, 26 May 2024 15:06:58 +0800
Subject: [PATCH] Improve conditional compilation for direct I/O alignment
checks
Signed-off-by: Zhao Junwang <[email protected]>
---
src/backend/storage/smgr/md.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index bf0f3ca76d..fa789045a1 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -465,9 +465,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
MdfdVec *v;
/* If this build supports direct I/O, the buffer must be I/O aligned. */
- if (PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ)
- Assert((uintptr_t) buffer == TYPEALIGN(PG_IO_ALIGN_SIZE, buffer));
-
+#if PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ
+ Assert((uintptr_t) buffer == TYPEALIGN(PG_IO_ALIGN_SIZE, buffer));
+#endif
/* This assert is too expensive to have on normally ... */
#ifdef CHECK_WRITE_VS_EXTEND
Assert(blocknum >= mdnblocks(reln, forknum));
@@ -767,12 +767,13 @@ buffers_to_iovec(struct iovec *iov, void **buffers, int nblocks)
Assert(nblocks >= 1);
/* If this build supports direct I/O, buffers must be I/O aligned. */
+#if PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ
for (int i = 0; i < nblocks; ++i)
{
- if (PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ)
- Assert((uintptr_t) buffers[i] ==
- TYPEALIGN(PG_IO_ALIGN_SIZE, buffers[i]));
+ Assert((uintptr_t) buffers[i] ==
+ TYPEALIGN(PG_IO_ALIGN_SIZE, buffers[i]));
}
+#endif
/* Start the first iovec off with the first buffer. */
iovp = &iov[0];
--
2.41.0
view thread (3+ messages) latest in thread
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]
Subject: Re: Improve conditional compilation for direct I/O alignment checks
In-Reply-To: <CAEG8a3J5w053U=O2+4_uxbXuMnmQFFVQef4GveV9QfW0wdeEaw@mail.gmail.com>
* 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