aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-03-22 11:45:07 -0700
committerAndres Freund <andres@anarazel.de>2018-03-22 11:51:58 -0700
commitcc415a56d09a8da7c919088036b6097b70f10791 (patch)
treeb99cb7e66041f8533dc63c4a689cbf3f03956957 /src/backend/executor
parent7ec0d80c0508eae35ac8e19d041f9ba1276de08e (diff)
downloadpostgresql-cc415a56d09a8da7c919088036b6097b70f10791.tar.gz
postgresql-cc415a56d09a8da7c919088036b6097b70f10791.zip
Basic planner and executor integration for JIT.
This adds simple cost based plan time decision about whether JIT should be performed. jit_above_cost, jit_optimize_above_cost are compared with the total cost of a plan, and if the cost is above them JIT is performed / optimization is performed respectively. For that PlannedStmt and EState have a jitFlags (es_jit_flags) field that stores information about what JIT operations should be performed. EState now also has a new es_jit field, which can store a JitContext. When there are no errors the context is released in standard_ExecutorEnd(). It is likely that the default values for jit_[optimize_]above_cost will need to be adapted further, but in my test these values seem to work reasonably. Author: Andres Freund, with feedback by Peter Eisentraut Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execMain.c8
-rw-r--r--src/backend/executor/execParallel.c3
-rw-r--r--src/backend/executor/execUtils.c3
3 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 91ba939bdca..890067757c0 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -48,6 +48,7 @@
#include "commands/trigger.h"
#include "executor/execdebug.h"
#include "foreign/fdwapi.h"
+#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
@@ -249,6 +250,9 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
estate->es_top_eflags = eflags;
estate->es_instrument = queryDesc->instrument_options;
+ if (queryDesc->plannedstmt)
+ estate->es_jit_flags = queryDesc->plannedstmt->jitFlags;
+
/*
* Set up an AFTER-trigger statement context, unless told not to, or
* unless it's EXPLAIN-only mode (when ExecutorFinish won't be called).
@@ -496,6 +500,10 @@ standard_ExecutorEnd(QueryDesc *queryDesc)
UnregisterSnapshot(estate->es_snapshot);
UnregisterSnapshot(estate->es_crosscheck_snapshot);
+ /* release JIT context, if allocated */
+ if (estate->es_jit)
+ jit_release_context(estate->es_jit);
+
/*
* Must switch out of context before destroying it
*/
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index 14b0b89463c..52f1a96db5f 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -73,6 +73,7 @@ typedef struct FixedParallelExecutorState
int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
dsa_pointer param_exec;
int eflags;
+ int jit_flags;
} FixedParallelExecutorState;
/*
@@ -680,6 +681,7 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
fpes->tuples_needed = tuples_needed;
fpes->param_exec = InvalidDsaPointer;
fpes->eflags = estate->es_top_eflags;
+ fpes->jit_flags = estate->es_jit_flags;
shm_toc_insert(pcxt->toc, PARALLEL_KEY_EXECUTOR_FIXED, fpes);
/* Store query string */
@@ -1287,6 +1289,7 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc)
area = dsa_attach_in_place(area_space, seg);
/* Start up the executor */
+ queryDesc->plannedstmt->jitFlags = fpes->jit_flags;
ExecutorStart(queryDesc, fpes->eflags);
/* Special executor initialization steps for parallel workers */
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index a8ae37ebc80..14b07b5d449 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -158,6 +158,9 @@ CreateExecutorState(void)
estate->es_use_parallel_mode = false;
+ estate->es_jit_flags = 0;
+ estate->es_jit = NULL;
+
/*
* Return the executor state structure
*/