diff options
author | Andres Freund <andres@anarazel.de> | 2018-09-25 12:54:29 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-09-25 13:12:44 -0700 |
commit | 33001fd7a7072d483272115a9376478fdc007fb9 (patch) | |
tree | 6a01a567ac1b665c34a2a7e97ece0bb2ea35b503 /src/backend/executor/execMain.c | |
parent | 5e22171310f8d7c82219a6b978440e5144e88683 (diff) | |
download | postgresql-33001fd7a7072d483272115a9376478fdc007fb9.tar.gz postgresql-33001fd7a7072d483272115a9376478fdc007fb9.zip |
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/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 85d980356b7..04f14c91787 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -48,6 +48,7 @@ #include "executor/execdebug.h" #include "executor/nodeSubplan.h" #include "foreign/fdwapi.h" +#include "jit/jit.h" #include "mb/pg_wchar.h" #include "miscadmin.h" #include "optimizer/clauses.h" @@ -494,6 +495,21 @@ standard_ExecutorEnd(QueryDesc *queryDesc) ExecEndPlan(queryDesc->planstate, estate); + /* + * If this process has done JIT, either merge stats into worker stats, or + * use this process' stats as the global stats if no parallelism was used + * / no workers did JIT. + */ + if (estate->es_instrument && queryDesc->estate->es_jit) + { + if (queryDesc->estate->es_jit_combined_instr) + InstrJitAgg(queryDesc->estate->es_jit_combined_instr, + &queryDesc->estate->es_jit->instr); + else + queryDesc->estate->es_jit_combined_instr = + &queryDesc->estate->es_jit->instr; + } + /* do away with our snapshots */ UnregisterSnapshot(estate->es_snapshot); UnregisterSnapshot(estate->es_crosscheck_snapshot); |