87
87
import static com .facebook .presto .SystemSessionProperties .isEagerPlanValidationEnabled ;
88
88
import static com .facebook .presto .SystemSessionProperties .isLogInvokedFunctionNamesEnabled ;
89
89
import static com .facebook .presto .SystemSessionProperties .isSpoolingOutputBufferEnabled ;
90
+ import static com .facebook .presto .common .RuntimeMetricName .ANALYZE_TIME_NANOS ;
91
+ import static com .facebook .presto .common .RuntimeMetricName .CREATE_SCHEDULER_TIME_NANOS ;
90
92
import static com .facebook .presto .common .RuntimeMetricName .FRAGMENT_PLAN_TIME_NANOS ;
91
93
import static com .facebook .presto .common .RuntimeMetricName .GET_CANONICAL_INFO_TIME_NANOS ;
92
94
import static com .facebook .presto .common .RuntimeMetricName .LOGICAL_PLANNER_TIME_NANOS ;
93
95
import static com .facebook .presto .common .RuntimeMetricName .OPTIMIZER_TIME_NANOS ;
96
+ import static com .facebook .presto .common .RuntimeMetricName .PLAN_AND_OPTIMIZE_TIME_NANOS ;
94
97
import static com .facebook .presto .execution .QueryStateMachine .pruneHistogramsFromStatsAndCosts ;
95
98
import static com .facebook .presto .execution .buffer .OutputBuffers .BROADCAST_PARTITION_ID ;
96
99
import static com .facebook .presto .execution .buffer .OutputBuffers .createInitialEmptyOutputBuffers ;
@@ -207,7 +210,9 @@ private SqlQueryExecution(
207
210
Thread .currentThread (),
208
211
timeoutThreadExecutor ,
209
212
getQueryAnalyzerTimeout (getSession ()))) {
210
- this .queryAnalysis = queryAnalyzer .analyze (analyzerContext , preparedQuery );
213
+ this .queryAnalysis = getSession ()
214
+ .getRuntimeStats ()
215
+ .recordWallAndCpuTime (ANALYZE_TIME_NANOS , () -> queryAnalyzer .analyze (analyzerContext , preparedQuery ));
211
216
}
212
217
213
218
stateMachine .setUpdateType (queryAnalysis .getUpdateType ());
@@ -482,7 +487,7 @@ public void start()
482
487
metadata .beginQuery (getSession (), plan .getConnectors ());
483
488
484
489
// plan distribution of query
485
- planDistribution ( plan );
490
+ getSession (). getRuntimeStats (). recordWallAndCpuTime ( CREATE_SCHEDULER_TIME_NANOS , () -> createQueryScheduler ( plan ) );
486
491
487
492
// transition to starting
488
493
if (!stateMachine .transitionToStarting ()) {
@@ -544,14 +549,23 @@ public void addFinalQueryInfoListener(StateChangeListener<QueryInfo> stateChange
544
549
}
545
550
546
551
private PlanRoot createLogicalPlanAndOptimize ()
552
+ {
553
+ return stateMachine .getSession ()
554
+ .getRuntimeStats ()
555
+ .recordWallAndCpuTime (
556
+ PLAN_AND_OPTIMIZE_TIME_NANOS ,
557
+ this ::doCreateLogicalPlanAndOptimize );
558
+ }
559
+
560
+ private PlanRoot doCreateLogicalPlanAndOptimize ()
547
561
{
548
562
try {
549
563
// time analysis phase
550
564
stateMachine .beginAnalysis ();
551
565
552
566
PlanNode planNode = stateMachine .getSession ()
553
567
.getRuntimeStats ()
554
- .profileNanos (
568
+ .recordWallAndCpuTime (
555
569
LOGICAL_PLANNER_TIME_NANOS ,
556
570
() -> queryAnalyzer .plan (this .analyzerContext , queryAnalysis ));
557
571
@@ -567,14 +581,14 @@ private PlanRoot createLogicalPlanAndOptimize()
567
581
costCalculator ,
568
582
false );
569
583
570
- Plan plan = getSession ().getRuntimeStats ().profileNanos (
584
+ Plan plan = getSession ().getRuntimeStats ().recordWallAndCpuTime (
571
585
OPTIMIZER_TIME_NANOS ,
572
586
() -> optimizer .validateAndOptimizePlan (planNode , OPTIMIZED_AND_VALIDATED ));
573
587
574
588
queryPlan .set (plan );
575
589
stateMachine .setPlanStatsAndCosts (plan .getStatsAndCosts ());
576
590
stateMachine .setPlanIdNodeMap (plan .getPlanIdNodeMap ());
577
- List <CanonicalPlanWithInfo > canonicalPlanWithInfos = getSession ().getRuntimeStats ().profileNanos (
591
+ List <CanonicalPlanWithInfo > canonicalPlanWithInfos = getSession ().getRuntimeStats ().recordWallAndCpuTime (
578
592
GET_CANONICAL_INFO_TIME_NANOS ,
579
593
() -> getCanonicalInfo (getSession (), plan .getRoot (), planCanonicalInfoProvider ));
580
594
stateMachine .setPlanCanonicalInfo (canonicalPlanWithInfos );
@@ -590,7 +604,7 @@ private PlanRoot createLogicalPlanAndOptimize()
590
604
// fragment the plan
591
605
// the variableAllocator is finally passed to SqlQueryScheduler for runtime cost-based optimizations
592
606
variableAllocator .set (new VariableAllocator (plan .getTypes ().allVariables ()));
593
- SubPlan fragmentedPlan = getSession ().getRuntimeStats ().profileNanos (
607
+ SubPlan fragmentedPlan = getSession ().getRuntimeStats ().recordWallAndCpuTime (
594
608
FRAGMENT_PLAN_TIME_NANOS ,
595
609
() -> planFragmenter .createSubPlans (stateMachine .getSession (), plan , false , idAllocator , variableAllocator .get (), stateMachine .getWarningCollector ()));
596
610
@@ -620,7 +634,7 @@ private PlanRoot runCreateLogicalPlanAsync()
620
634
}
621
635
}
622
636
623
- private void planDistribution (PlanRoot plan )
637
+ private void createQueryScheduler (PlanRoot plan )
624
638
{
625
639
CloseableSplitSourceProvider splitSourceProvider = new CloseableSplitSourceProvider (splitManager ::getSplits );
626
640
0 commit comments