v13-0012-WIP-read_stream-Issue-IO-synchronously-while-in-.patch
application/octet-stream
Filename: v13-0012-WIP-read_stream-Issue-IO-synchronously-while-in-.patch
Type: application/octet-stream
Part: 8
Message:
Re: index prefetching
Patch
Format: format-patch
Series: patch v13-0012
Subject: WIP: read_stream: Issue IO synchronously while in fast path
| File | + | − |
|---|---|---|
| src/backend/storage/aio/read_stream.c | 15 | 0 |
From da79f0b2e65f5262e986d300ba94fc1d2a64e73c Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Tue, 3 Mar 2026 16:25:41 -0500
Subject: [PATCH v13 12/19] WIP: read_stream: Issue IO synchronously while in
fast path
While in fast-path, execute any IO that we might encounter
synchronously. Because we are, right now, not reading ahead, dispatching any
occasional IO to workers would have the overhead of dispatching to workers,
without any realistic chance of the IO completing before we need it.
Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
src/backend/storage/aio/read_stream.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/backend/storage/aio/read_stream.c b/src/backend/storage/aio/read_stream.c
index cd54c1a74..3667d67ab 100644
--- a/src/backend/storage/aio/read_stream.c
+++ b/src/backend/storage/aio/read_stream.c
@@ -833,6 +833,19 @@ read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
if (stream->advice_enabled)
flags |= READ_BUFFERS_ISSUE_ADVICE;
+ /*
+ * While in fast-path, execute any IO that we might encounter
+ * synchronously. Because we are, right now, not reading ahead,
+ * dispatching any occasional IO to workers would have the
+ * overhead of dispatching to workers, without any realistic
+ * chance of the IO completing before we need it. We will switch
+ * to non-synchronous IO after this.
+ *
+ * XXX: Should we do so only for worker, or also io_uring? There's
+ * not much dispatch overhead with io_uring, compared to worker...
+ */
+ flags |= READ_BUFFERS_SYNCHRONOUSLY;
+
/*
* Pin a buffer for the next call. Same buffer entry, and
* arbitrary I/O entry (they're all free). We don't have to
@@ -860,6 +873,8 @@ read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
stream->ios_in_progress = 1;
stream->ios[0].buffer_index = oldest_buffer_index;
stream->seq_blocknum = next_blocknum + 1;
+
+ /* FIXME: it would probably worth issuing readahead here */
}
else
{
--
2.53.0