diff options
| author | Andres Freund | 2018-09-25 19:54:29 +0000 |
|---|---|---|
| committer | Andres Freund | 2018-09-25 20:12:44 +0000 |
| commit | 33001fd7a7072d483272115a9376478fdc007fb9 (patch) | |
| tree | 6a01a567ac1b665c34a2a7e97ece0bb2ea35b503 /src/include | |
| parent | 5e22171310f8d7c82219a6b978440e5144e88683 (diff) | |
Collect JIT instrumentation from workers.
Previously, when using parallel query, EXPLAIN (ANALYZE)'s JIT
compilation timings did not include the overhead from doing so on the
workers. Fix that.
We do so by simply aggregating the cost of doing JIT compilation on
workers and the leader together. Arguably that's not quite accurate,
because the total time spend doing so is spent in parallel - but it's
hard to do much better. For additional detail, when VERBOSE is
specified, the stats for workers are displayed separately.
Author: Amit Khandekar and Andres Freund
Discussion: https://postgr.es/m/CAJ3gD9eLrz51RK_gTkod+71iDcjpB_N8eC6vU2AW-VicsAERpQ@mail.gmail.com
Backpatch: 11-
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/commands/explain.h | 3 | ||||
| -rw-r--r-- | src/include/executor/execParallel.h | 1 | ||||
| -rw-r--r-- | src/include/jit/jit.h | 27 | ||||
| -rw-r--r-- | src/include/nodes/execnodes.h | 8 |
4 files changed, 32 insertions, 7 deletions
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h index 9b75baae6e6..b0b6f1e15a4 100644 --- a/src/include/commands/explain.h +++ b/src/include/commands/explain.h @@ -81,7 +81,8 @@ extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc); extern void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc); -extern void ExplainPrintJIT(ExplainState *es, QueryDesc *queryDesc); +extern void ExplainPrintJIT(ExplainState *es, int jit_flags, + struct JitInstrumentation *jit_instr, int worker_i); extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc); diff --git a/src/include/executor/execParallel.h b/src/include/executor/execParallel.h index 626a66c27a0..1b4c35e5f14 100644 --- a/src/include/executor/execParallel.h +++ b/src/include/executor/execParallel.h @@ -27,6 +27,7 @@ typedef struct ParallelExecutorInfo ParallelContext *pcxt; /* parallel context we're using */ BufferUsage *buffer_usage; /* points to bufusage area in DSM */ SharedExecutorInstrumentation *instrumentation; /* optional */ + struct SharedJitInstrumentation *jit_instrumentation; /* optional */ dsa_area *area; /* points to DSA area in DSM */ dsa_pointer param_exec; /* serialized PARAM_EXEC parameters */ bool finished; /* set true by ExecParallelFinish */ diff --git a/src/include/jit/jit.h b/src/include/jit/jit.h index b451f4027e7..6cb3bdc89f0 100644 --- a/src/include/jit/jit.h +++ b/src/include/jit/jit.h @@ -24,13 +24,8 @@ #define PGJIT_DEFORM (1 << 4) -typedef struct JitContext +typedef struct JitInstrumentation { - /* see PGJIT_* above */ - int flags; - - ResourceOwner resowner; - /* number of emitted functions */ size_t created_functions; @@ -45,6 +40,25 @@ typedef struct JitContext /* accumulated time for code emission */ instr_time emission_counter; +} JitInstrumentation; + +/* + * DSM structure for accumulating jit instrumentation of all workers. + */ +typedef struct SharedJitInstrumentation +{ + int num_workers; + JitInstrumentation jit_instr[FLEXIBLE_ARRAY_MEMBER]; +} SharedJitInstrumentation; + +typedef struct JitContext +{ + /* see PGJIT_* above */ + int flags; + + ResourceOwner resowner; + + JitInstrumentation instr; } JitContext; typedef struct JitProviderCallbacks JitProviderCallbacks; @@ -85,6 +99,7 @@ extern void jit_release_context(JitContext *context); * not be able to perform JIT (i.e. return false). */ extern bool jit_compile_expr(struct ExprState *state); +extern void InstrJitAgg(JitInstrumentation *dst, JitInstrumentation *add); #endif /* JIT_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 687d7cd2f41..03ad5169762 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -569,9 +569,14 @@ typedef struct EState * JIT information. es_jit_flags indicates whether JIT should be performed * and with which options. es_jit is created on-demand when JITing is * performed. + * + * es_jit_combined_instr, at the end of query execution with + * instrumentation enabled, is the the combined instrumentation + * information of leader and followers. */ int es_jit_flags; struct JitContext *es_jit; + struct JitInstrumentation *es_jit_combined_instr; } EState; @@ -923,6 +928,9 @@ typedef struct PlanState Instrumentation *instrument; /* Optional runtime stats for this node */ WorkerInstrumentation *worker_instrument; /* per-worker instrumentation */ + /* Per-worker JIT instrumentation */ + struct SharedJitInstrumentation *worker_jit_instrument; + /* * Common structural data for all Plan types. These links to subsidiary * state trees parallel links in the associated plan tree (except for the |
