Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc03c144

Browse files
committed
Fix issues around EXPLAIN with JIT.
I (Andres) was more than a bit hasty in committing33001fdafter last minute changes, leading to a number of problems (jit outputwas only shown for JIT in parallel workers, and just EXPLAIN withoutANALYZE didn't work). Lukas luckily found these issues quickly.Instead of combining instrumentation in in standard_ExecutorEnd(), doso on demand in the new ExplainPrintJITSummary().Also update a documentation example of the JIT output, changed in52050ad.Author: Lukas Fittl, with minor changes by meDiscussion:https://postgr.es/m/CAP53PkxmgJht69pabxBXJBM+0oc6kf3KHMborLP7H2ouJ0CCtQ@mail.gmail.comBackpatch: 11, where JIT compilation was introduced
1 parent595a0ea commitc03c144

File tree

7 files changed

+39
-34
lines changed

7 files changed

+39
-34
lines changed

‎contrib/auto_explain/auto_explain.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
363363
if (es->analyze&&auto_explain_log_triggers)
364364
ExplainPrintTriggers(es,queryDesc);
365365
if (es->costs)
366-
ExplainPrintJIT(es,queryDesc->estate->es_jit_flags,
367-
queryDesc->estate->es_jit_combined_instr,-1);
366+
ExplainPrintJITSummary(es,queryDesc);
368367
ExplainEndOutput(es);
369368

370369
/* Remove last line break */

‎doc/src/sgml/jit.sgml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,8 @@ SET
169169
Planning Time: 0.133 ms
170170
JIT:
171171
Functions: 3
172-
Generation Time: 1.259 ms
173-
Inlining: false
174-
Inlining Time: 0.000 ms
175-
Optimization: false
176-
Optimization Time: 0.797 ms
177-
Emission Time: 5.048 ms
172+
Options: Inlining false, Optimization false, Expressions true, Deforming true
173+
Timing: Generation 1.259 ms, Inlining 0.000 ms, Optimization 0.797 ms, Emission 5.048 ms, Total 7.104 ms
178174
Execution Time: 7.416 ms
179175
</screen>
180176
As visible here, <acronym>JIT</acronym> was used, but inlining and

‎src/backend/commands/explain.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
564564
* at a later stage.
565565
*/
566566
if (es->costs)
567-
ExplainPrintJIT(es,queryDesc->estate->es_jit_flags,
568-
queryDesc->estate->es_jit_combined_instr,-1);
567+
ExplainPrintJITSummary(es,queryDesc);
569568

570569
/*
571570
* Close down the query and free resources. Include time for this in the
@@ -688,6 +687,32 @@ ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc)
688687
ExplainCloseGroup("Triggers","Triggers", false,es);
689688
}
690689

690+
/*
691+
* ExplainPrintJITSummary -
692+
* Print summarized JIT instrumentation from leader and workers
693+
*/
694+
void
695+
ExplainPrintJITSummary(ExplainState*es,QueryDesc*queryDesc)
696+
{
697+
JitInstrumentationji= {0};
698+
699+
if (!(queryDesc->estate->es_jit_flags&PGJIT_PERFORM))
700+
return;
701+
702+
/*
703+
* Work with a copy instead of modifying the leader state, since this
704+
* function may be called twice
705+
*/
706+
if (queryDesc->estate->es_jit)
707+
InstrJitAgg(&ji,&queryDesc->estate->es_jit->instr);
708+
709+
/* If this process has done JIT in parallel workers, merge stats */
710+
if (queryDesc->estate->es_jit_worker_instr)
711+
InstrJitAgg(&ji,queryDesc->estate->es_jit_worker_instr);
712+
713+
ExplainPrintJIT(es,queryDesc->estate->es_jit_flags,&ji,-1);
714+
}
715+
691716
/*
692717
* ExplainPrintJIT -
693718
* Append information about JITing to es->str.

‎src/backend/executor/execMain.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -495,21 +495,6 @@ standard_ExecutorEnd(QueryDesc *queryDesc)
495495

496496
ExecEndPlan(queryDesc->planstate,estate);
497497

498-
/*
499-
* If this process has done JIT, either merge stats into worker stats, or
500-
* use this process' stats as the global stats if no parallelism was used
501-
* / no workers did JIT.
502-
*/
503-
if (estate->es_instrument&&queryDesc->estate->es_jit)
504-
{
505-
if (queryDesc->estate->es_jit_combined_instr)
506-
InstrJitAgg(queryDesc->estate->es_jit_combined_instr,
507-
&queryDesc->estate->es_jit->instr);
508-
else
509-
queryDesc->estate->es_jit_combined_instr=
510-
&queryDesc->estate->es_jit->instr;
511-
}
512-
513498
/* do away with our snapshots */
514499
UnregisterSnapshot(estate->es_snapshot);
515500
UnregisterSnapshot(estate->es_crosscheck_snapshot);

‎src/backend/executor/execParallel.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,13 +1043,12 @@ ExecParallelRetrieveJitInstrumentation(PlanState *planstate,
10431043

10441044
/*
10451045
* Accumulate worker JIT instrumentation into the combined JIT
1046-
* instrumentation, allocating it if required. Note this is kept separate
1047-
* from the leader's own instrumentation.
1046+
* instrumentation, allocating it if required.
10481047
*/
1049-
if (!planstate->state->es_jit_combined_instr)
1050-
planstate->state->es_jit_combined_instr=
1048+
if (!planstate->state->es_jit_worker_instr)
1049+
planstate->state->es_jit_worker_instr=
10511050
MemoryContextAllocZero(planstate->state->es_query_cxt,sizeof(JitInstrumentation));
1052-
combined=planstate->state->es_jit_combined_instr;
1051+
combined=planstate->state->es_jit_worker_instr;
10531052

10541053
/* Accummulate all the workers' instrumentations. */
10551054
for (n=0;n<shared_jit->num_workers;++n)

‎src/include/commands/explain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
8181
externvoidExplainPrintPlan(ExplainState*es,QueryDesc*queryDesc);
8282
externvoidExplainPrintTriggers(ExplainState*es,QueryDesc*queryDesc);
8383

84+
externvoidExplainPrintJITSummary(ExplainState*es,QueryDesc*queryDesc);
8485
externvoidExplainPrintJIT(ExplainState*es,intjit_flags,
8586
structJitInstrumentation*jit_instr,intworker_i);
8687

‎src/include/nodes/execnodes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,13 @@ typedef struct EState
570570
* and with which options. es_jit is created on-demand when JITing is
571571
* performed.
572572
*
573-
* es_jit_combined_instr, at theend of query execution with
574-
* instrumentationenabled, is the the combined instrumentation
575-
*information of leader and followers.
573+
* es_jit_combined_instr is thethe combined, on demand allocated,
574+
* instrumentationfrom all workers. The leader's instrumentation is kept
575+
*separate, and is combined on demand by ExplainPrintJITSummary().
576576
*/
577577
intes_jit_flags;
578578
structJitContext*es_jit;
579-
structJitInstrumentation*es_jit_combined_instr;
579+
structJitInstrumentation*es_jit_worker_instr;
580580
}EState;
581581

582582

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp