Skip to content

Commit 488f826

Browse files
committed
bufmgr: Return early in ScheduleBufferTagForWriteback() if fsync=off
As pg_flush_data() doesn't do anything with fsync disabled, there's no point in tracking the buffer for writeback. Arguably the better fix would be to change pg_flush_data() to flush data even with fsync off, but that's a behavioral change, whereas this is just a small optimization. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/1f6b50a7-38ef-4d87-8246-786d39f46ab9@iki.fi
1 parent c01fd93 commit 488f826

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5899,7 +5899,12 @@ ScheduleBufferTagForWriteback(WritebackContext *wb_context, IOContext io_context
58995899
{
59005900
PendingWriteback *pending;
59015901

5902-
if (io_direct_flags & IO_DIRECT_DATA)
5902+
/*
5903+
* As pg_flush_data() doesn't do anything with fsync disabled, there's no
5904+
* point in tracking in that case.
5905+
*/
5906+
if (io_direct_flags & IO_DIRECT_DATA ||
5907+
!enableFsync)
59035908
return;
59045909

59055910
/*

0 commit comments

Comments
 (0)