Skip to content

Commit

Permalink
[trinodb#31] Expose three more query-related time statistics in Query…
Browse files Browse the repository at this point in the history
…Manager
  • Loading branch information
杨金德 committed Mar 28, 2023
1 parent 96c2306 commit 7d3d8fc
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class QueryManagerStats
private final CounterStat consumedCpuTimeSecs = new CounterStat();
private final TimeStat executionTime = new TimeStat(MILLISECONDS);
private final TimeStat queuedTime = new TimeStat(MILLISECONDS);
private final TimeStat elapsedTime = new TimeStat(MILLISECONDS);
private final TimeStat analysisTime = new TimeStat(MILLISECONDS);
private final TimeStat planningTime = new TimeStat(MILLISECONDS);
private final DistributionStat wallInputBytesRate = new DistributionStat();
private final DistributionStat cpuInputByteRate = new DistributionStat();

Expand Down Expand Up @@ -82,6 +85,9 @@ private void queryFinished(BasicQueryInfo info)
consumedInputRows.update(info.getQueryStats().getRawInputPositions());
executionTime.add(info.getQueryStats().getExecutionTime());
queuedTime.add(info.getQueryStats().getQueuedTime());
elapsedTime.add(info.getQueryStats().getElapsedTime());
analysisTime.add(info.getQueryStats().getAnalysisTime());
planningTime.add(info.getQueryStats().getPlanningTime());

long executionWallMillis = info.getQueryStats().getExecutionTime().toMillis();
if (executionWallMillis > 0) {
Expand Down Expand Up @@ -225,6 +231,27 @@ public TimeStat getQueuedTime()
return queuedTime;
}

@Managed
@Nested
public TimeStat getElapsedTime()
{
return elapsedTime;
}

@Managed
@Nested
public TimeStat getAnalysisTime()
{
return analysisTime;
}

@Managed
@Nested
public TimeStat getPlanningTime()
{
return planningTime;
}

@Managed
@Nested
public CounterStat getUserErrorFailures()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageStats> rootStage)
queryStateTimer.getQueuedTime(),
queryStateTimer.getElapsedTime(),
queryStateTimer.getExecutionTime(),
queryStateTimer.getAnalysisTime(),
queryStateTimer.getPlanningTime(),

stageStats.getFailedTasks(),

Expand Down
22 changes: 22 additions & 0 deletions core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class BasicQueryStats
private final Duration queuedTime;
private final Duration elapsedTime;
private final Duration executionTime;
private final Duration analysisTime;
private final Duration planningTime;

private final int failedTasks;

Expand Down Expand Up @@ -79,6 +81,8 @@ public BasicQueryStats(
@JsonProperty("queuedTime") Duration queuedTime,
@JsonProperty("elapsedTime") Duration elapsedTime,
@JsonProperty("executionTime") Duration executionTime,
@JsonProperty("analysisTime") Duration analysisTime,
@JsonProperty("planningTime") Duration planningTime,
@JsonProperty("failedTasks") int failedTasks,
@JsonProperty("totalDrivers") int totalDrivers,
@JsonProperty("queuedDrivers") int queuedDrivers,
Expand Down Expand Up @@ -107,6 +111,8 @@ public BasicQueryStats(
this.queuedTime = requireNonNull(queuedTime, "queuedTime is null");
this.elapsedTime = requireNonNull(elapsedTime, "elapsedTime is null");
this.executionTime = requireNonNull(executionTime, "executionTime is null");
this.analysisTime = requireNonNull(analysisTime, "analysisTime is null");
this.planningTime = requireNonNull(planningTime, "planningTime is null");

checkArgument(failedTasks >= 0, "failedTasks is negative");
this.failedTasks = failedTasks;
Expand Down Expand Up @@ -148,6 +154,8 @@ public BasicQueryStats(QueryStats queryStats)
queryStats.getQueuedTime(),
queryStats.getElapsedTime(),
queryStats.getExecutionTime(),
queryStats.getAnalysisTime(),
queryStats.getPlanningTime(),
queryStats.getFailedTasks(),
queryStats.getTotalDrivers(),
queryStats.getQueuedDrivers(),
Expand Down Expand Up @@ -180,6 +188,8 @@ public static BasicQueryStats immediateFailureQueryStats()
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
0,
0,
0,
Expand Down Expand Up @@ -233,6 +243,18 @@ public Duration getExecutionTime()
return executionTime;
}

@JsonProperty
public Duration getAnalysisTime()
{
return analysisTime;
}

@JsonProperty
public Duration getPlanningTime()
{
return planningTime;
}

@JsonProperty
public int getFailedTasks()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public BasicQueryInfo getBasicQueryInfo()
new Duration(3, NANOSECONDS),
new Duration(4, NANOSECONDS),
new Duration(5, NANOSECONDS),
new Duration(23, NANOSECONDS),
new Duration(24, NANOSECONDS),
99,
6,
7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public void testConstructor()
assertEquals(basicInfo.getQueryStats().getEndTime(), DateTime.parse("1991-09-06T06:00-05:30"));
assertEquals(basicInfo.getQueryStats().getElapsedTime(), new Duration(8, MINUTES));
assertEquals(basicInfo.getQueryStats().getExecutionTime(), new Duration(44, MINUTES));
assertEquals(basicInfo.getQueryStats().getAnalysisTime(), new Duration(9, MINUTES));
assertEquals(basicInfo.getQueryStats().getPlanningTime(), new Duration(99, SECONDS));

assertEquals(basicInfo.getQueryStats().getTotalDrivers(), 17);
assertEquals(basicInfo.getQueryStats().getQueuedDrivers(), 18);
Expand Down
10 changes: 10 additions & 0 deletions plugin/trino-iceberg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private static BasicQueryInfo createQueryInfo(String queryId, QueryState state)
new Duration(8, MINUTES),
new Duration(7, MINUTES),
new Duration(34, MINUTES),
new Duration(35, MINUTES),
new Duration(36, MINUTES),
99,
13,
14,
Expand Down

0 comments on commit 7d3d8fc

Please sign in to comment.