mirror of
https://github.com/postgres/postgres.git
synced 2025-11-22 12:22:45 +03:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user