1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-18 04:29:09 +03:00

Rename fields in pgstat structures for functions and relations

This commit renames the members of a few pgstat structures related to
functions and relations, by respectively removing their prefix "f_" and
"t_".  The statistics for functions and relations and handled in their
own file, and pgstatfuncs.c associates each field in a structure
variable named based on the object type handled, so no information is
lost with this rename.

This will help with some of the refactoring aimed for pgstatfuncs.c, as
this makes more consistent the field names with the SQL functions
retrieving them.

Author: Bertrand Drouvot
Reviewed-by: Michael Paquier, Melanie Plageman
Discussion: https://postgr.es/m/9142f62a-a422-145c-bde0-b5bc498a4ada@gmail.com
This commit is contained in:
Michael Paquier
2023-03-24 08:46:29 +09:00
parent 11a0a8b529
commit 8089517ab8
4 changed files with 142 additions and 142 deletions

View File

@@ -124,13 +124,13 @@ pgstat_init_function_usage(FunctionCallInfo fcinfo,
fcu->fs = pending;
/* save stats for this function, later used to compensate for recursion */
fcu->save_f_total_time = pending->f_total_time;
fcu->save_f_total_time = pending->total_time;
/* save current backend-wide total time */
fcu->save_total = total_func_time;
/* get clock time as of function start */
INSTR_TIME_SET_CURRENT(fcu->f_start);
INSTR_TIME_SET_CURRENT(fcu->start);
}
/*
@@ -146,41 +146,41 @@ void
pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
{
PgStat_FunctionCounts *fs = fcu->fs;
instr_time f_total;
instr_time f_others;
instr_time f_self;
instr_time total;
instr_time others;
instr_time self;
/* stats not wanted? */
if (fs == NULL)
return;
/* total elapsed time in this function call */
INSTR_TIME_SET_CURRENT(f_total);
INSTR_TIME_SUBTRACT(f_total, fcu->f_start);
INSTR_TIME_SET_CURRENT(total);
INSTR_TIME_SUBTRACT(total, fcu->start);
/* self usage: elapsed minus anything already charged to other calls */
f_others = total_func_time;
INSTR_TIME_SUBTRACT(f_others, fcu->save_total);
f_self = f_total;
INSTR_TIME_SUBTRACT(f_self, f_others);
others = total_func_time;
INSTR_TIME_SUBTRACT(others, fcu->save_total);
self = total;
INSTR_TIME_SUBTRACT(self, others);
/* update backend-wide total time */
INSTR_TIME_ADD(total_func_time, f_self);
INSTR_TIME_ADD(total_func_time, self);
/*
* Compute the new f_total_time as the total elapsed time added to the
* pre-call value of f_total_time. This is necessary to avoid
* Compute the new total_time as the total elapsed time added to the
* pre-call value of total_time. This is necessary to avoid
* double-counting any time taken by recursive calls of myself. (We do
* not need any similar kluge for self time, since that already excludes
* any recursive calls.)
*/
INSTR_TIME_ADD(f_total, fcu->save_f_total_time);
INSTR_TIME_ADD(total, fcu->save_f_total_time);
/* update counters in function stats table */
if (finalize)
fs->f_numcalls++;
fs->f_total_time = f_total;
INSTR_TIME_ADD(fs->f_self_time, f_self);
fs->numcalls++;
fs->total_time = total;
INSTR_TIME_ADD(fs->self_time, self);
}
/*
@@ -203,11 +203,11 @@ pgstat_function_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
if (!pgstat_lock_entry(entry_ref, nowait))
return false;
shfuncent->stats.f_numcalls += localent->f_numcalls;
shfuncent->stats.f_total_time +=
INSTR_TIME_GET_MICROSEC(localent->f_total_time);
shfuncent->stats.f_self_time +=
INSTR_TIME_GET_MICROSEC(localent->f_self_time);
shfuncent->stats.numcalls += localent->numcalls;
shfuncent->stats.total_time +=
INSTR_TIME_GET_MICROSEC(localent->total_time);
shfuncent->stats.self_time +=
INSTR_TIME_GET_MICROSEC(localent->self_time);
pgstat_unlock_entry(entry_ref);