From 8089517ab8b547daab78f404f99eb48fba91ee9d Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Fri, 24 Mar 2023 08:46:29 +0900 Subject: 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 --- src/backend/utils/activity/pgstat_function.c | 46 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/backend/utils/activity/pgstat_function.c') diff --git a/src/backend/utils/activity/pgstat_function.c b/src/backend/utils/activity/pgstat_function.c index 0fdcefb7832..79e781167b0 100644 --- a/src/backend/utils/activity/pgstat_function.c +++ b/src/backend/utils/activity/pgstat_function.c @@ -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); -- cgit v1.2.3