diff options
| author | Michael Paquier | 2023-12-16 19:16:20 +0000 |
|---|---|---|
| committer | Michael Paquier | 2023-12-16 19:16:20 +0000 |
| commit | 3c9d9acae0bc0cd2f905043cb1d581baec4622c4 (patch) | |
| tree | b5dd28cef30e14e3c88c2ba2e233784f42d84e10 /src/backend/utils | |
| parent | a6be0600ac3b71dda8277ab0fcbe59ee101ac1ce (diff) | |
Refactor pgstat_prepare_io_time() with an input argument instead of a GUC
Originally, this routine relied on track_io_timing to check if a time
interval for an I/O operation stored in pg_stat_io should be initialized
or not. However, the addition of WAL statistics to pg_stat_io requires
that the initialization happens when track_wal_io_timing is enabled,
which is dependent on the code path where the I/O operation happens.
Author: Nazir Bilal Yavuz
Discussion: https://postgr.es/m/CAN55FZ3AiQ+ZMxUuXnBpd0Rrh1YhwJ5FudkHg=JU0P+-W8T4Vg@mail.gmail.com
Diffstat (limited to 'src/backend/utils')
| -rw-r--r-- | src/backend/utils/activity/pgstat_io.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/activity/pgstat_io.c index 490d5a9ab79..d99ecdd4d8e 100644 --- a/src/backend/utils/activity/pgstat_io.c +++ b/src/backend/utils/activity/pgstat_io.c @@ -92,15 +92,25 @@ pgstat_count_io_op_n(IOObject io_object, IOContext io_context, IOOp io_op, uint3 have_iostats = true; } +/* + * Initialize the internal timing for an IO operation, depending on an + * IO timing GUC. + */ instr_time -pgstat_prepare_io_time(void) +pgstat_prepare_io_time(bool track_io_guc) { instr_time io_start; - if (track_io_timing) + if (track_io_guc) INSTR_TIME_SET_CURRENT(io_start); else + { + /* + * There is no need to set io_start when an IO timing GUC is disabled, + * still initialize it to zero to avoid compiler warnings. + */ INSTR_TIME_SET_ZERO(io_start); + } return io_start; } |
