mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add JIT deform_counter
generation_counter includes time spent on both JIT:ing expressions and tuple deforming which are configured independently via options jit_expressions and jit_tuple_deforming. As they are combined in the same counter it's not apparent what fraction of time the tuple deforming takes. This adds deform_counter dedicated to tuple deforming, which allows seeing more directly the influence jit_tuple_deforming is having on the query. The counter is exposed in EXPLAIN and pg_stat_statements bumpin pg_stat_statements to 1.11. Author: Dmitry Dolgov <9erthalion6@gmail.com> Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/20220612091253.eegstkufdsu4kfls@erthalion.local
This commit is contained in:
@ -117,7 +117,8 @@ typedef enum pgssVersion
|
||||
PGSS_V1_3,
|
||||
PGSS_V1_8,
|
||||
PGSS_V1_9,
|
||||
PGSS_V1_10
|
||||
PGSS_V1_10,
|
||||
PGSS_V1_11
|
||||
} pgssVersion;
|
||||
|
||||
typedef enum pgssStoreKind
|
||||
@ -192,6 +193,10 @@ typedef struct Counters
|
||||
double jit_generation_time; /* total time to generate jit code */
|
||||
int64 jit_inlining_count; /* number of times inlining time has been
|
||||
* > 0 */
|
||||
double jit_deform_time; /* total time to deform tuples in jit code */
|
||||
int64 jit_deform_count; /* number of times deform time has been >
|
||||
* 0 */
|
||||
|
||||
double jit_inlining_time; /* total time to inline jit code */
|
||||
int64 jit_optimization_count; /* number of times optimization time
|
||||
* has been > 0 */
|
||||
@ -312,6 +317,7 @@ PG_FUNCTION_INFO_V1(pg_stat_statements_1_3);
|
||||
PG_FUNCTION_INFO_V1(pg_stat_statements_1_8);
|
||||
PG_FUNCTION_INFO_V1(pg_stat_statements_1_9);
|
||||
PG_FUNCTION_INFO_V1(pg_stat_statements_1_10);
|
||||
PG_FUNCTION_INFO_V1(pg_stat_statements_1_11);
|
||||
PG_FUNCTION_INFO_V1(pg_stat_statements);
|
||||
PG_FUNCTION_INFO_V1(pg_stat_statements_info);
|
||||
|
||||
@ -1398,6 +1404,10 @@ pgss_store(const char *query, uint64 queryId,
|
||||
e->counters.jit_functions += jitusage->created_functions;
|
||||
e->counters.jit_generation_time += INSTR_TIME_GET_MILLISEC(jitusage->generation_counter);
|
||||
|
||||
if (INSTR_TIME_GET_MILLISEC(jitusage->deform_counter))
|
||||
e->counters.jit_deform_count++;
|
||||
e->counters.jit_deform_time += INSTR_TIME_GET_MILLISEC(jitusage->deform_counter);
|
||||
|
||||
if (INSTR_TIME_GET_MILLISEC(jitusage->inlining_counter))
|
||||
e->counters.jit_inlining_count++;
|
||||
e->counters.jit_inlining_time += INSTR_TIME_GET_MILLISEC(jitusage->inlining_counter);
|
||||
@ -1460,7 +1470,8 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
|
||||
#define PG_STAT_STATEMENTS_COLS_V1_8 32
|
||||
#define PG_STAT_STATEMENTS_COLS_V1_9 33
|
||||
#define PG_STAT_STATEMENTS_COLS_V1_10 43
|
||||
#define PG_STAT_STATEMENTS_COLS 43 /* maximum of above */
|
||||
#define PG_STAT_STATEMENTS_COLS_V1_11 45
|
||||
#define PG_STAT_STATEMENTS_COLS 45 /* maximum of above */
|
||||
|
||||
/*
|
||||
* Retrieve statement statistics.
|
||||
@ -1472,6 +1483,16 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
|
||||
* expected API version is identified by embedding it in the C name of the
|
||||
* function. Unfortunately we weren't bright enough to do that for 1.1.
|
||||
*/
|
||||
Datum
|
||||
pg_stat_statements_1_11(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool showtext = PG_GETARG_BOOL(0);
|
||||
|
||||
pg_stat_statements_internal(fcinfo, PGSS_V1_11, showtext);
|
||||
|
||||
return (Datum) 0;
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_statements_1_10(PG_FUNCTION_ARGS)
|
||||
{
|
||||
@ -1602,6 +1623,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
|
||||
if (api_version != PGSS_V1_10)
|
||||
elog(ERROR, "incorrect number of output arguments");
|
||||
break;
|
||||
case PG_STAT_STATEMENTS_COLS_V1_11:
|
||||
if (api_version != PGSS_V1_11)
|
||||
elog(ERROR, "incorrect number of output arguments");
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "incorrect number of output arguments");
|
||||
}
|
||||
@ -1834,6 +1859,11 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
|
||||
values[i++] = Int64GetDatumFast(tmp.jit_emission_count);
|
||||
values[i++] = Float8GetDatumFast(tmp.jit_emission_time);
|
||||
}
|
||||
if (api_version >= PGSS_V1_11)
|
||||
{
|
||||
values[i++] = Int64GetDatumFast(tmp.jit_deform_count);
|
||||
values[i++] = Float8GetDatumFast(tmp.jit_deform_time);
|
||||
}
|
||||
|
||||
Assert(i == (api_version == PGSS_V1_0 ? PG_STAT_STATEMENTS_COLS_V1_0 :
|
||||
api_version == PGSS_V1_1 ? PG_STAT_STATEMENTS_COLS_V1_1 :
|
||||
@ -1842,6 +1872,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
|
||||
api_version == PGSS_V1_8 ? PG_STAT_STATEMENTS_COLS_V1_8 :
|
||||
api_version == PGSS_V1_9 ? PG_STAT_STATEMENTS_COLS_V1_9 :
|
||||
api_version == PGSS_V1_10 ? PG_STAT_STATEMENTS_COLS_V1_10 :
|
||||
api_version == PGSS_V1_11 ? PG_STAT_STATEMENTS_COLS_V1_11 :
|
||||
-1 /* fail if you forget to update this assert */ ));
|
||||
|
||||
tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
|
||||
|
Reference in New Issue
Block a user