Skip to content

Commit 4ce424d

Browse files
committed
aio: Experimental heuristics to increase batching in read_stream.c
Author: Reviewed-by: Discussion: https://postgr.es/m/ Backpatch:
1 parent 11f0ca7 commit 4ce424d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/backend/storage/aio/read_stream.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,30 @@ read_stream_start_pending_read(ReadStream *stream)
404404
static void
405405
read_stream_look_ahead(ReadStream *stream)
406406
{
407+
/*
408+
* Batch-submitting multiple IOs is more efficient than doing so
409+
* one-by-one. If we just ramp up to the max, we'll only be allowed to
410+
* submit one io_combine_limit sized IO. Defer submitting IO in that case.
411+
*
412+
* FIXME: This needs better heuristics.
413+
*/
414+
#if 1
415+
if (!stream->sync_mode && stream->distance > (io_combine_limit * 8))
416+
{
417+
if (stream->pinned_buffers + stream->pending_read_nblocks > ((stream->distance * 3) / 4))
418+
{
419+
#if 0
420+
ereport(LOG,
421+
errmsg("reduce reduce reduce: pinned: %d, pending: %d, distance: %d",
422+
stream->pinned_buffers,
423+
stream->pending_read_nblocks,
424+
stream->distance));
425+
#endif
426+
return;
427+
}
428+
}
429+
#endif
430+
407431
/*
408432
* Allow amortizing the cost of submitting IO over multiple IOs. This
409433
* requires that we don't do any operations that could lead to a deadlock

0 commit comments

Comments
 (0)