Skip to content

Commit e731aea

Browse files
committed
Remove PgStat_BackendFunctionEntry
This structure included only PgStat_FunctionCounts, and removing it facilitates some upcoming refactoring for pgstatfuncs.c to use more macros rather that mostly-duplicated functions. Author: Bertrand Drouvot Reviewed-by: Nathan Bossart Discussion: https://postgr.es/m/11d531fe-52fc-c6ea-7e8e-62f1b6ec626e@gmail.com
1 parent e643a31 commit e731aea

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

src/backend/utils/activity/pgstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static const PgStat_KindInfo pgstat_kind_infos[PGSTAT_NUM_KINDS] = {
292292
.shared_size = sizeof(PgStatShared_Function),
293293
.shared_data_off = offsetof(PgStatShared_Function, stats),
294294
.shared_data_len = sizeof(((PgStatShared_Function *) 0)->stats),
295-
.pending_size = sizeof(PgStat_BackendFunctionEntry),
295+
.pending_size = sizeof(PgStat_FunctionCounts),
296296

297297
.flush_pending_cb = pgstat_function_flush_cb,
298298
},

src/backend/utils/activity/pgstat_function.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pgstat_init_function_usage(FunctionCallInfo fcinfo,
7373
PgStat_FunctionCallUsage *fcu)
7474
{
7575
PgStat_EntryRef *entry_ref;
76-
PgStat_BackendFunctionEntry *pending;
76+
PgStat_FunctionCounts *pending;
7777
bool created_entry;
7878

7979
if (pgstat_track_functions <= fcinfo->flinfo->fn_stats)
@@ -121,10 +121,10 @@ pgstat_init_function_usage(FunctionCallInfo fcinfo,
121121

122122
pending = entry_ref->pending;
123123

124-
fcu->fs = &pending->f_counts;
124+
fcu->fs = pending;
125125

126126
/* save stats for this function, later used to compensate for recursion */
127-
fcu->save_f_total_time = pending->f_counts.f_total_time;
127+
fcu->save_f_total_time = pending->f_total_time;
128128

129129
/* save current backend-wide total time */
130130
fcu->save_total = total_func_time;
@@ -192,34 +192,34 @@ pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
192192
bool
193193
pgstat_function_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
194194
{
195-
PgStat_BackendFunctionEntry *localent;
195+
PgStat_FunctionCounts *localent;
196196
PgStatShared_Function *shfuncent;
197197

198-
localent = (PgStat_BackendFunctionEntry *) entry_ref->pending;
198+
localent = (PgStat_FunctionCounts *) entry_ref->pending;
199199
shfuncent = (PgStatShared_Function *) entry_ref->shared_stats;
200200

201201
/* localent always has non-zero content */
202202

203203
if (!pgstat_lock_entry(entry_ref, nowait))
204204
return false;
205205

206-
shfuncent->stats.f_numcalls += localent->f_counts.f_numcalls;
206+
shfuncent->stats.f_numcalls += localent->f_numcalls;
207207
shfuncent->stats.f_total_time +=
208-
INSTR_TIME_GET_MICROSEC(localent->f_counts.f_total_time);
208+
INSTR_TIME_GET_MICROSEC(localent->f_total_time);
209209
shfuncent->stats.f_self_time +=
210-
INSTR_TIME_GET_MICROSEC(localent->f_counts.f_self_time);
210+
INSTR_TIME_GET_MICROSEC(localent->f_self_time);
211211

212212
pgstat_unlock_entry(entry_ref);
213213

214214
return true;
215215
}
216216

217217
/*
218-
* find any existing PgStat_BackendFunctionEntry entry for specified function
218+
* find any existing PgStat_FunctionCounts entry for specified function
219219
*
220220
* If no entry, return NULL, don't create a new one
221221
*/
222-
PgStat_BackendFunctionEntry *
222+
PgStat_FunctionCounts *
223223
find_funcstat_entry(Oid func_id)
224224
{
225225
PgStat_EntryRef *entry_ref;

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,33 +1652,33 @@ Datum
16521652
pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
16531653
{
16541654
Oid funcid = PG_GETARG_OID(0);
1655-
PgStat_BackendFunctionEntry *funcentry;
1655+
PgStat_FunctionCounts *funcentry;
16561656

16571657
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
16581658
PG_RETURN_NULL();
1659-
PG_RETURN_INT64(funcentry->f_counts.f_numcalls);
1659+
PG_RETURN_INT64(funcentry->f_numcalls);
16601660
}
16611661

16621662
Datum
16631663
pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS)
16641664
{
16651665
Oid funcid = PG_GETARG_OID(0);
1666-
PgStat_BackendFunctionEntry *funcentry;
1666+
PgStat_FunctionCounts *funcentry;
16671667

16681668
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
16691669
PG_RETURN_NULL();
1670-
PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_counts.f_total_time));
1670+
PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_total_time));
16711671
}
16721672

16731673
Datum
16741674
pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
16751675
{
16761676
Oid funcid = PG_GETARG_OID(0);
1677-
PgStat_BackendFunctionEntry *funcentry;
1677+
PgStat_FunctionCounts *funcentry;
16781678

16791679
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
16801680
PG_RETURN_NULL();
1681-
PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_counts.f_self_time));
1681+
PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_self_time));
16821682
}
16831683

16841684

src/include/pgstat.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,6 @@ typedef struct PgStat_FunctionCounts
111111
instr_time f_self_time;
112112
} PgStat_FunctionCounts;
113113

114-
/* ----------
115-
* PgStat_BackendFunctionEntry Non-flushed function stats.
116-
* ----------
117-
*/
118-
typedef struct PgStat_BackendFunctionEntry
119-
{
120-
PgStat_FunctionCounts f_counts;
121-
} PgStat_BackendFunctionEntry;
122-
123114
/*
124115
* Working state needed to accumulate per-function-call timing statistics.
125116
*/
@@ -556,7 +547,7 @@ extern void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu,
556547
bool finalize);
557548

558549
extern PgStat_StatFuncEntry *pgstat_fetch_stat_funcentry(Oid func_id);
559-
extern PgStat_BackendFunctionEntry *find_funcstat_entry(Oid func_id);
550+
extern PgStat_FunctionCounts *find_funcstat_entry(Oid func_id);
560551

561552

562553
/*

src/tools/pgindent/typedefs.list

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,6 @@ PgStatShared_SLRU
20322032
PgStatShared_Subscription
20332033
PgStatShared_Wal
20342034
PgStat_ArchiverStats
2035-
PgStat_BackendFunctionEntry
20362035
PgStat_BackendSubEntry
20372036
PgStat_BgWriterStats
20382037
PgStat_BktypeIO

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy