Search in sources :

Example 1 with StageGcStatistics

use of io.trino.spi.eventlistener.StageGcStatistics in project trino by trinodb.

the class StageStateMachine method getStageInfo.

public StageInfo getStageInfo(Supplier<Iterable<TaskInfo>> taskInfosSupplier) {
    Optional<StageInfo> finalStageInfo = this.finalStageInfo.get();
    if (finalStageInfo.isPresent()) {
        return finalStageInfo.get();
    }
    // stage state must be captured first in order to provide a
    // consistent view of the stage. For example, building this
    // information, the stage could finish, and the task states would
    // never be visible.
    StageState state = stageState.get();
    List<TaskInfo> taskInfos = ImmutableList.copyOf(taskInfosSupplier.get());
    int totalTasks = taskInfos.size();
    int runningTasks = 0;
    int completedTasks = 0;
    int failedTasks = 0;
    int totalDrivers = 0;
    int queuedDrivers = 0;
    int runningDrivers = 0;
    int blockedDrivers = 0;
    int completedDrivers = 0;
    long cumulativeUserMemory = 0;
    long failedCumulativeUserMemory = 0;
    long userMemoryReservation = 0;
    long revocableMemoryReservation = 0;
    long totalMemoryReservation = 0;
    long peakUserMemoryReservation = peakUserMemory.get();
    long peakRevocableMemoryReservation = peakRevocableMemory.get();
    long totalScheduledTime = 0;
    long failedScheduledTime = 0;
    long totalCpuTime = 0;
    long failedCpuTime = 0;
    long totalBlockedTime = 0;
    long physicalInputDataSize = 0;
    long failedPhysicalInputDataSize = 0;
    long physicalInputPositions = 0;
    long failedPhysicalInputPositions = 0;
    long physicalInputReadTime = 0;
    long failedPhysicalInputReadTime = 0;
    long internalNetworkInputDataSize = 0;
    long failedInternalNetworkInputDataSize = 0;
    long internalNetworkInputPositions = 0;
    long failedInternalNetworkInputPositions = 0;
    long rawInputDataSize = 0;
    long failedRawInputDataSize = 0;
    long rawInputPositions = 0;
    long failedRawInputPositions = 0;
    long processedInputDataSize = 0;
    long failedProcessedInputDataSize = 0;
    long processedInputPositions = 0;
    long failedProcessedInputPositions = 0;
    long bufferedDataSize = 0;
    long outputDataSize = 0;
    long failedOutputDataSize = 0;
    long outputPositions = 0;
    long failedOutputPositions = 0;
    long physicalWrittenDataSize = 0;
    long failedPhysicalWrittenDataSize = 0;
    int fullGcCount = 0;
    int fullGcTaskCount = 0;
    int minFullGcSec = 0;
    int maxFullGcSec = 0;
    int totalFullGcSec = 0;
    boolean fullyBlocked = true;
    Set<BlockedReason> blockedReasons = new HashSet<>();
    Map<String, OperatorStats> operatorToStats = new HashMap<>();
    for (TaskInfo taskInfo : taskInfos) {
        TaskState taskState = taskInfo.getTaskStatus().getState();
        if (taskState.isDone()) {
            completedTasks++;
        } else {
            runningTasks++;
        }
        if (taskState == TaskState.FAILED) {
            failedTasks++;
        }
        TaskStats taskStats = taskInfo.getStats();
        totalDrivers += taskStats.getTotalDrivers();
        queuedDrivers += taskStats.getQueuedDrivers();
        runningDrivers += taskStats.getRunningDrivers();
        blockedDrivers += taskStats.getBlockedDrivers();
        completedDrivers += taskStats.getCompletedDrivers();
        cumulativeUserMemory += taskStats.getCumulativeUserMemory();
        if (taskState == TaskState.FAILED) {
            failedCumulativeUserMemory += taskStats.getCumulativeUserMemory();
        }
        long taskUserMemory = taskStats.getUserMemoryReservation().toBytes();
        long taskRevocableMemory = taskStats.getRevocableMemoryReservation().toBytes();
        userMemoryReservation += taskUserMemory;
        revocableMemoryReservation += taskRevocableMemory;
        totalMemoryReservation += taskUserMemory + taskRevocableMemory;
        totalScheduledTime += taskStats.getTotalScheduledTime().roundTo(NANOSECONDS);
        totalCpuTime += taskStats.getTotalCpuTime().roundTo(NANOSECONDS);
        totalBlockedTime += taskStats.getTotalBlockedTime().roundTo(NANOSECONDS);
        if (taskState == TaskState.FAILED) {
            failedScheduledTime += taskStats.getTotalScheduledTime().roundTo(NANOSECONDS);
            failedCpuTime += taskStats.getTotalCpuTime().roundTo(NANOSECONDS);
        }
        if (!taskState.isDone()) {
            fullyBlocked &= taskStats.isFullyBlocked();
            blockedReasons.addAll(taskStats.getBlockedReasons());
        }
        physicalInputDataSize += taskStats.getPhysicalInputDataSize().toBytes();
        physicalInputPositions += taskStats.getPhysicalInputPositions();
        physicalInputReadTime += taskStats.getPhysicalInputReadTime().roundTo(NANOSECONDS);
        internalNetworkInputDataSize += taskStats.getInternalNetworkInputDataSize().toBytes();
        internalNetworkInputPositions += taskStats.getInternalNetworkInputPositions();
        rawInputDataSize += taskStats.getRawInputDataSize().toBytes();
        rawInputPositions += taskStats.getRawInputPositions();
        processedInputDataSize += taskStats.getProcessedInputDataSize().toBytes();
        processedInputPositions += taskStats.getProcessedInputPositions();
        bufferedDataSize += taskInfo.getOutputBuffers().getTotalBufferedBytes();
        outputDataSize += taskStats.getOutputDataSize().toBytes();
        outputPositions += taskStats.getOutputPositions();
        physicalWrittenDataSize += taskStats.getPhysicalWrittenDataSize().toBytes();
        if (taskState == TaskState.FAILED) {
            failedPhysicalInputDataSize += taskStats.getPhysicalInputDataSize().toBytes();
            failedPhysicalInputPositions += taskStats.getPhysicalInputPositions();
            failedPhysicalInputReadTime += taskStats.getPhysicalInputReadTime().roundTo(NANOSECONDS);
            failedInternalNetworkInputDataSize += taskStats.getInternalNetworkInputDataSize().toBytes();
            failedInternalNetworkInputPositions += taskStats.getInternalNetworkInputPositions();
            failedRawInputDataSize += taskStats.getRawInputDataSize().toBytes();
            failedRawInputPositions += taskStats.getRawInputPositions();
            failedProcessedInputDataSize += taskStats.getProcessedInputDataSize().toBytes();
            failedProcessedInputPositions += taskStats.getProcessedInputPositions();
            failedOutputDataSize += taskStats.getOutputDataSize().toBytes();
            failedOutputPositions += taskStats.getOutputPositions();
            failedPhysicalWrittenDataSize += taskStats.getPhysicalWrittenDataSize().toBytes();
        }
        fullGcCount += taskStats.getFullGcCount();
        fullGcTaskCount += taskStats.getFullGcCount() > 0 ? 1 : 0;
        int gcSec = toIntExact(taskStats.getFullGcTime().roundTo(SECONDS));
        totalFullGcSec += gcSec;
        minFullGcSec = min(minFullGcSec, gcSec);
        maxFullGcSec = max(maxFullGcSec, gcSec);
        for (PipelineStats pipeline : taskStats.getPipelines()) {
            for (OperatorStats operatorStats : pipeline.getOperatorSummaries()) {
                String id = pipeline.getPipelineId() + "." + operatorStats.getOperatorId();
                operatorToStats.compute(id, (k, v) -> v == null ? operatorStats : v.add(operatorStats));
            }
        }
    }
    StageStats stageStats = new StageStats(schedulingComplete.get(), getSplitDistribution.snapshot(), totalTasks, runningTasks, completedTasks, failedTasks, totalDrivers, queuedDrivers, runningDrivers, blockedDrivers, completedDrivers, cumulativeUserMemory, failedCumulativeUserMemory, succinctBytes(userMemoryReservation), succinctBytes(revocableMemoryReservation), succinctBytes(totalMemoryReservation), succinctBytes(peakUserMemoryReservation), succinctBytes(peakRevocableMemoryReservation), succinctDuration(totalScheduledTime, NANOSECONDS), succinctDuration(failedScheduledTime, NANOSECONDS), succinctDuration(totalCpuTime, NANOSECONDS), succinctDuration(failedCpuTime, NANOSECONDS), succinctDuration(totalBlockedTime, NANOSECONDS), fullyBlocked && runningTasks > 0, blockedReasons, succinctBytes(physicalInputDataSize), succinctBytes(failedPhysicalInputDataSize), physicalInputPositions, failedPhysicalInputPositions, succinctDuration(physicalInputReadTime, NANOSECONDS), succinctDuration(failedPhysicalInputReadTime, NANOSECONDS), succinctBytes(internalNetworkInputDataSize), succinctBytes(failedInternalNetworkInputDataSize), internalNetworkInputPositions, failedInternalNetworkInputPositions, succinctBytes(rawInputDataSize), succinctBytes(failedRawInputDataSize), rawInputPositions, failedRawInputPositions, succinctBytes(processedInputDataSize), succinctBytes(failedProcessedInputDataSize), processedInputPositions, failedProcessedInputPositions, succinctBytes(bufferedDataSize), succinctBytes(outputDataSize), succinctBytes(failedOutputDataSize), outputPositions, failedOutputPositions, succinctBytes(physicalWrittenDataSize), succinctBytes(failedPhysicalWrittenDataSize), new StageGcStatistics(stageId.getId(), totalTasks, fullGcTaskCount, minFullGcSec, maxFullGcSec, totalFullGcSec, (int) (1.0 * totalFullGcSec / fullGcCount)), ImmutableList.copyOf(operatorToStats.values()));
    ExecutionFailureInfo failureInfo = null;
    if (state == FAILED) {
        failureInfo = failureCause.get();
    }
    return new StageInfo(stageId, state, fragment, fragment.getPartitioning().isCoordinatorOnly(), fragment.getTypes(), stageStats, taskInfos, ImmutableList.of(), tables, failureInfo);
}
Also used : PipelineStats(io.trino.operator.PipelineStats) BlockedReason(io.trino.operator.BlockedReason) HashMap(java.util.HashMap) OperatorStats(io.trino.operator.OperatorStats) TaskStats(io.trino.operator.TaskStats) StageGcStatistics(io.trino.spi.eventlistener.StageGcStatistics) HashSet(java.util.HashSet)

Example 2 with StageGcStatistics

use of io.trino.spi.eventlistener.StageGcStatistics in project trino by trinodb.

the class TestQueryStats method assertExpectedQueryStats.

public static void assertExpectedQueryStats(QueryStats actual) {
    assertEquals(actual.getCreateTime(), new DateTime(1, UTC));
    assertEquals(actual.getExecutionStartTime(), new DateTime(2, UTC));
    assertEquals(actual.getLastHeartbeat(), new DateTime(3, UTC));
    assertEquals(actual.getEndTime(), new DateTime(4, UTC));
    assertEquals(actual.getElapsedTime(), new Duration(6, NANOSECONDS));
    assertEquals(actual.getQueuedTime(), new Duration(5, NANOSECONDS));
    assertEquals(actual.getResourceWaitingTime(), new Duration(31, NANOSECONDS));
    assertEquals(actual.getDispatchingTime(), new Duration(32, NANOSECONDS));
    assertEquals(actual.getExecutionTime(), new Duration(41, NANOSECONDS));
    assertEquals(actual.getAnalysisTime(), new Duration(33, NANOSECONDS));
    assertEquals(actual.getPlanningTime(), new Duration(100, NANOSECONDS));
    assertEquals(actual.getFinishingTime(), new Duration(200, NANOSECONDS));
    assertEquals(actual.getTotalTasks(), 9);
    assertEquals(actual.getRunningTasks(), 10);
    assertEquals(actual.getCompletedTasks(), 11);
    assertEquals(actual.getFailedTasks(), 12);
    assertEquals(actual.getTotalDrivers(), 13);
    assertEquals(actual.getQueuedDrivers(), 14);
    assertEquals(actual.getRunningDrivers(), 15);
    assertEquals(actual.getBlockedDrivers(), 30);
    assertEquals(actual.getCompletedDrivers(), 16);
    assertEquals(actual.getCumulativeUserMemory(), 17.0);
    assertEquals(actual.getFailedCumulativeUserMemory(), 18.0);
    assertEquals(actual.getUserMemoryReservation(), DataSize.ofBytes(19));
    assertEquals(actual.getRevocableMemoryReservation(), DataSize.ofBytes(20));
    assertEquals(actual.getTotalMemoryReservation(), DataSize.ofBytes(21));
    assertEquals(actual.getPeakUserMemoryReservation(), DataSize.ofBytes(22));
    assertEquals(actual.getPeakRevocableMemoryReservation(), DataSize.ofBytes(23));
    assertEquals(actual.getPeakTotalMemoryReservation(), DataSize.ofBytes(24));
    assertEquals(actual.getPeakTaskUserMemory(), DataSize.ofBytes(25));
    assertEquals(actual.getPeakTaskRevocableMemory(), DataSize.ofBytes(26));
    assertEquals(actual.getPeakTaskTotalMemory(), DataSize.ofBytes(27));
    assertEquals(actual.getSpilledDataSize(), DataSize.ofBytes(693));
    assertEquals(actual.getTotalScheduledTime(), new Duration(28, NANOSECONDS));
    assertEquals(actual.getFailedScheduledTime(), new Duration(29, NANOSECONDS));
    assertEquals(actual.getTotalCpuTime(), new Duration(30, NANOSECONDS));
    assertEquals(actual.getFailedCpuTime(), new Duration(31, NANOSECONDS));
    assertEquals(actual.getTotalBlockedTime(), new Duration(32, NANOSECONDS));
    assertEquals(actual.getPhysicalInputDataSize(), DataSize.ofBytes(241));
    assertEquals(actual.getFailedPhysicalInputDataSize(), DataSize.ofBytes(242));
    assertEquals(actual.getPhysicalInputPositions(), 251);
    assertEquals(actual.getFailedPhysicalInputPositions(), 252);
    assertEquals(actual.getPhysicalInputReadTime(), new Duration(33, NANOSECONDS));
    assertEquals(actual.getFailedPhysicalInputReadTime(), new Duration(34, NANOSECONDS));
    assertEquals(actual.getInternalNetworkInputDataSize(), DataSize.ofBytes(242));
    assertEquals(actual.getFailedInternalNetworkInputDataSize(), DataSize.ofBytes(243));
    assertEquals(actual.getInternalNetworkInputPositions(), 253);
    assertEquals(actual.getFailedInternalNetworkInputPositions(), 254);
    assertEquals(actual.getRawInputDataSize(), DataSize.ofBytes(35));
    assertEquals(actual.getFailedRawInputDataSize(), DataSize.ofBytes(36));
    assertEquals(actual.getRawInputPositions(), 37);
    assertEquals(actual.getFailedRawInputPositions(), 38);
    assertEquals(actual.getProcessedInputDataSize(), DataSize.ofBytes(39));
    assertEquals(actual.getFailedProcessedInputDataSize(), DataSize.ofBytes(40));
    assertEquals(actual.getProcessedInputPositions(), 41);
    assertEquals(actual.getFailedProcessedInputPositions(), 42);
    assertEquals(actual.getOutputDataSize(), DataSize.ofBytes(43));
    assertEquals(actual.getFailedOutputDataSize(), DataSize.ofBytes(44));
    assertEquals(actual.getOutputPositions(), 45);
    assertEquals(actual.getFailedOutputPositions(), 46);
    assertEquals(actual.getPhysicalWrittenDataSize(), DataSize.ofBytes(47));
    assertEquals(actual.getFailedPhysicalWrittenDataSize(), DataSize.ofBytes(48));
    assertEquals(actual.getStageGcStatistics().size(), 1);
    StageGcStatistics gcStatistics = actual.getStageGcStatistics().get(0);
    assertEquals(gcStatistics.getStageId(), 101);
    assertEquals(gcStatistics.getTasks(), 102);
    assertEquals(gcStatistics.getFullGcTasks(), 103);
    assertEquals(gcStatistics.getMinFullGcSec(), 104);
    assertEquals(gcStatistics.getMaxFullGcSec(), 105);
    assertEquals(gcStatistics.getTotalFullGcSec(), 106);
    assertEquals(gcStatistics.getAverageFullGcSec(), 107);
    assertEquals(420, actual.getWrittenPositions());
    assertEquals(58, actual.getLogicalWrittenDataSize().toBytes());
    assertEquals(DynamicFiltersStats.EMPTY, actual.getDynamicFiltersStats());
}
Also used : Duration(io.airlift.units.Duration) StageGcStatistics(io.trino.spi.eventlistener.StageGcStatistics) DateTime(org.joda.time.DateTime)

Example 3 with StageGcStatistics

use of io.trino.spi.eventlistener.StageGcStatistics in project trino by trinodb.

the class TestBasicQueryInfo method testConstructor.

@Test
public void testConstructor() {
    BasicQueryInfo basicInfo = new BasicQueryInfo(new QueryInfo(new QueryId("0"), TEST_SESSION.toSessionRepresentation(), RUNNING, false, URI.create("1"), ImmutableList.of("2", "3"), "SELECT 4", Optional.empty(), new QueryStats(DateTime.parse("1991-09-06T05:00-05:30"), DateTime.parse("1991-09-06T05:01-05:30"), DateTime.parse("1991-09-06T05:02-05:30"), DateTime.parse("1991-09-06T06:00-05:30"), new Duration(8, MINUTES), new Duration(7, MINUTES), new Duration(35, MINUTES), new Duration(35, MINUTES), new Duration(44, MINUTES), new Duration(9, MINUTES), new Duration(99, SECONDS), new Duration(12, MINUTES), 13, 14, 15, 16, 17, 18, 19, 34, 20, 21.0, 22.0, DataSize.valueOf("23GB"), DataSize.valueOf("24GB"), DataSize.valueOf("25GB"), DataSize.valueOf("26GB"), DataSize.valueOf("27GB"), DataSize.valueOf("28GB"), DataSize.valueOf("29GB"), DataSize.valueOf("30GB"), DataSize.valueOf("31GB"), true, new Duration(32, MINUTES), new Duration(33, MINUTES), new Duration(34, MINUTES), new Duration(35, MINUTES), new Duration(36, MINUTES), true, ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY), DataSize.valueOf("271GB"), DataSize.valueOf("271GB"), 281, 281, new Duration(37, MINUTES), new Duration(38, MINUTES), DataSize.valueOf("272GB"), DataSize.valueOf("272GB"), 282, 282, DataSize.valueOf("39GB"), DataSize.valueOf("40GB"), 41, 42, DataSize.valueOf("43GB"), DataSize.valueOf("44GB"), 45, 46, DataSize.valueOf("47GB"), DataSize.valueOf("48GB"), 49, 50, DataSize.valueOf("51GB"), DataSize.valueOf("52GB"), ImmutableList.of(new StageGcStatistics(101, 102, 103, 104, 105, 106, 107)), DynamicFiltersStats.EMPTY, ImmutableList.of()), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(), ImmutableSet.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty(), false, "33", Optional.empty(), null, StandardErrorCode.ABANDONED_QUERY.toErrorCode(), ImmutableList.of(), ImmutableSet.of(), Optional.empty(), ImmutableList.of(), ImmutableList.of(), false, Optional.empty(), Optional.of(QueryType.SELECT)));
    assertEquals(basicInfo.getQueryId().getId(), "0");
    assertEquals(basicInfo.getState(), RUNNING);
    assertEquals(basicInfo.isScheduled(), false);
    assertEquals(basicInfo.getQuery(), "SELECT 4");
    assertEquals(basicInfo.getQueryType().get(), QueryType.SELECT);
    assertEquals(basicInfo.getQueryStats().getCreateTime(), DateTime.parse("1991-09-06T05:00-05:30"));
    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().getTotalDrivers(), 17);
    assertEquals(basicInfo.getQueryStats().getQueuedDrivers(), 18);
    assertEquals(basicInfo.getQueryStats().getRunningDrivers(), 19);
    assertEquals(basicInfo.getQueryStats().getCompletedDrivers(), 20);
    assertEquals(basicInfo.getQueryStats().getCumulativeUserMemory(), 21.0);
    assertEquals(basicInfo.getQueryStats().getFailedCumulativeUserMemory(), 22.0);
    assertEquals(basicInfo.getQueryStats().getUserMemoryReservation(), DataSize.valueOf("23GB"));
    assertEquals(basicInfo.getQueryStats().getTotalMemoryReservation(), DataSize.valueOf("25GB"));
    assertEquals(basicInfo.getQueryStats().getPeakUserMemoryReservation(), DataSize.valueOf("26GB"));
    assertEquals(basicInfo.getQueryStats().getTotalScheduledTime(), new Duration(32, MINUTES));
    assertEquals(basicInfo.getQueryStats().getFailedScheduledTime(), new Duration(33, MINUTES));
    assertEquals(basicInfo.getQueryStats().getTotalCpuTime(), new Duration(34, MINUTES));
    assertEquals(basicInfo.getQueryStats().getFailedCpuTime(), new Duration(35, MINUTES));
    assertEquals(basicInfo.getQueryStats().isFullyBlocked(), true);
    assertEquals(basicInfo.getQueryStats().getBlockedReasons(), ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY));
    assertEquals(basicInfo.getQueryStats().getProgressPercentage(), OptionalDouble.of(100));
    assertEquals(basicInfo.getErrorCode(), StandardErrorCode.ABANDONED_QUERY.toErrorCode());
    assertEquals(basicInfo.getErrorType(), StandardErrorCode.ABANDONED_QUERY.toErrorCode().getType());
}
Also used : QueryStats(io.trino.execution.QueryStats) QueryId(io.trino.spi.QueryId) Duration(io.airlift.units.Duration) QueryInfo(io.trino.execution.QueryInfo) StageGcStatistics(io.trino.spi.eventlistener.StageGcStatistics) Test(org.testng.annotations.Test)

Example 4 with StageGcStatistics

use of io.trino.spi.eventlistener.StageGcStatistics in project trino by trinodb.

the class QueryStateMachine method getQueryStats.

private QueryStats getQueryStats(Optional<StageInfo> rootStage) {
    int totalTasks = 0;
    int runningTasks = 0;
    int completedTasks = 0;
    int failedTasks = 0;
    int totalDrivers = 0;
    int queuedDrivers = 0;
    int runningDrivers = 0;
    int blockedDrivers = 0;
    int completedDrivers = 0;
    long cumulativeUserMemory = 0;
    long failedCumulativeUserMemory = 0;
    long userMemoryReservation = 0;
    long revocableMemoryReservation = 0;
    long totalMemoryReservation = 0;
    long totalScheduledTime = 0;
    long failedScheduledTime = 0;
    long totalCpuTime = 0;
    long failedCpuTime = 0;
    long totalBlockedTime = 0;
    long physicalInputDataSize = 0;
    long failedPhysicalInputDataSize = 0;
    long physicalInputPositions = 0;
    long failedPhysicalInputPositions = 0;
    long physicalInputReadTime = 0;
    long failedPhysicalInputReadTime = 0;
    long internalNetworkInputDataSize = 0;
    long failedInternalNetworkInputDataSize = 0;
    long internalNetworkInputPositions = 0;
    long failedInternalNetworkInputPositions = 0;
    long rawInputDataSize = 0;
    long failedRawInputDataSize = 0;
    long rawInputPositions = 0;
    long failedRawInputPositions = 0;
    long processedInputDataSize = 0;
    long failedProcessedInputDataSize = 0;
    long processedInputPositions = 0;
    long failedProcessedInputPositions = 0;
    long outputDataSize = 0;
    long failedOutputDataSize = 0;
    long outputPositions = 0;
    long failedOutputPositions = 0;
    long physicalWrittenDataSize = 0;
    long failedPhysicalWrittenDataSize = 0;
    ImmutableList.Builder<StageGcStatistics> stageGcStatistics = ImmutableList.builder();
    boolean fullyBlocked = rootStage.isPresent();
    Set<BlockedReason> blockedReasons = new HashSet<>();
    ImmutableList.Builder<OperatorStats> operatorStatsSummary = ImmutableList.builder();
    boolean completeInfo = true;
    for (StageInfo stageInfo : getAllStages(rootStage)) {
        StageStats stageStats = stageInfo.getStageStats();
        totalTasks += stageStats.getTotalTasks();
        runningTasks += stageStats.getRunningTasks();
        completedTasks += stageStats.getCompletedTasks();
        failedTasks += stageStats.getFailedTasks();
        totalDrivers += stageStats.getTotalDrivers();
        queuedDrivers += stageStats.getQueuedDrivers();
        runningDrivers += stageStats.getRunningDrivers();
        blockedDrivers += stageStats.getBlockedDrivers();
        completedDrivers += stageStats.getCompletedDrivers();
        cumulativeUserMemory += stageStats.getCumulativeUserMemory();
        failedCumulativeUserMemory += stageStats.getFailedCumulativeUserMemory();
        userMemoryReservation += stageStats.getUserMemoryReservation().toBytes();
        revocableMemoryReservation += stageStats.getRevocableMemoryReservation().toBytes();
        totalMemoryReservation += stageStats.getTotalMemoryReservation().toBytes();
        totalScheduledTime += stageStats.getTotalScheduledTime().roundTo(MILLISECONDS);
        failedScheduledTime += stageStats.getFailedScheduledTime().roundTo(MILLISECONDS);
        totalCpuTime += stageStats.getTotalCpuTime().roundTo(MILLISECONDS);
        failedCpuTime += stageStats.getFailedCpuTime().roundTo(MILLISECONDS);
        totalBlockedTime += stageStats.getTotalBlockedTime().roundTo(MILLISECONDS);
        if (!stageInfo.getState().isDone()) {
            fullyBlocked &= stageStats.isFullyBlocked();
            blockedReasons.addAll(stageStats.getBlockedReasons());
        }
        physicalInputDataSize += stageStats.getPhysicalInputDataSize().toBytes();
        failedPhysicalInputDataSize += stageStats.getFailedPhysicalInputDataSize().toBytes();
        physicalInputPositions += stageStats.getPhysicalInputPositions();
        failedPhysicalInputPositions += stageStats.getFailedPhysicalInputPositions();
        physicalInputReadTime += stageStats.getPhysicalInputReadTime().roundTo(MILLISECONDS);
        failedPhysicalInputReadTime += stageStats.getFailedPhysicalInputReadTime().roundTo(MILLISECONDS);
        internalNetworkInputDataSize += stageStats.getInternalNetworkInputDataSize().toBytes();
        failedInternalNetworkInputDataSize += stageStats.getFailedInternalNetworkInputDataSize().toBytes();
        internalNetworkInputPositions += stageStats.getInternalNetworkInputPositions();
        failedInternalNetworkInputPositions += stageStats.getFailedInternalNetworkInputPositions();
        PlanFragment plan = stageInfo.getPlan();
        if (plan != null && plan.getPartitionedSourceNodes().stream().anyMatch(TableScanNode.class::isInstance)) {
            rawInputDataSize += stageStats.getRawInputDataSize().toBytes();
            failedRawInputDataSize += stageStats.getFailedRawInputDataSize().toBytes();
            rawInputPositions += stageStats.getRawInputPositions();
            failedRawInputPositions += stageStats.getFailedRawInputPositions();
            processedInputDataSize += stageStats.getProcessedInputDataSize().toBytes();
            failedProcessedInputDataSize += stageStats.getFailedProcessedInputDataSize().toBytes();
            processedInputPositions += stageStats.getProcessedInputPositions();
            failedProcessedInputPositions += stageStats.getFailedProcessedInputPositions();
        }
        physicalWrittenDataSize += stageStats.getPhysicalWrittenDataSize().toBytes();
        failedPhysicalWrittenDataSize += stageStats.getFailedPhysicalWrittenDataSize().toBytes();
        stageGcStatistics.add(stageStats.getGcInfo());
        completeInfo = completeInfo && stageInfo.isCompleteInfo();
        operatorStatsSummary.addAll(stageInfo.getStageStats().getOperatorSummaries());
    }
    if (rootStage.isPresent()) {
        StageStats outputStageStats = rootStage.get().getStageStats();
        outputDataSize += outputStageStats.getOutputDataSize().toBytes();
        failedOutputDataSize += outputStageStats.getFailedOutputDataSize().toBytes();
        outputPositions += outputStageStats.getOutputPositions();
        failedOutputPositions += outputStageStats.getFailedOutputPositions();
    }
    boolean isScheduled = isScheduled(rootStage);
    return new QueryStats(queryStateTimer.getCreateTime(), getExecutionStartTime().orElse(null), getLastHeartbeat(), getEndTime().orElse(null), queryStateTimer.getElapsedTime(), queryStateTimer.getQueuedTime(), queryStateTimer.getResourceWaitingTime(), queryStateTimer.getDispatchingTime(), queryStateTimer.getExecutionTime(), queryStateTimer.getAnalysisTime(), queryStateTimer.getPlanningTime(), queryStateTimer.getFinishingTime(), totalTasks, runningTasks, completedTasks, failedTasks, totalDrivers, queuedDrivers, runningDrivers, blockedDrivers, completedDrivers, cumulativeUserMemory, failedCumulativeUserMemory, succinctBytes(userMemoryReservation), succinctBytes(revocableMemoryReservation), succinctBytes(totalMemoryReservation), succinctBytes(getPeakUserMemoryInBytes()), succinctBytes(getPeakRevocableMemoryInBytes()), succinctBytes(getPeakTotalMemoryInBytes()), succinctBytes(getPeakTaskUserMemory()), succinctBytes(getPeakTaskRevocableMemory()), succinctBytes(getPeakTaskTotalMemory()), isScheduled, new Duration(totalScheduledTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), new Duration(failedScheduledTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), new Duration(totalCpuTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), new Duration(failedCpuTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), new Duration(totalBlockedTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), fullyBlocked, blockedReasons, succinctBytes(physicalInputDataSize), succinctBytes(failedPhysicalInputDataSize), physicalInputPositions, failedPhysicalInputPositions, new Duration(physicalInputReadTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), new Duration(failedPhysicalInputReadTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), succinctBytes(internalNetworkInputDataSize), succinctBytes(failedInternalNetworkInputDataSize), internalNetworkInputPositions, failedInternalNetworkInputPositions, succinctBytes(rawInputDataSize), succinctBytes(failedRawInputDataSize), rawInputPositions, failedRawInputPositions, succinctBytes(processedInputDataSize), succinctBytes(failedProcessedInputDataSize), processedInputPositions, failedProcessedInputPositions, succinctBytes(outputDataSize), succinctBytes(failedOutputDataSize), outputPositions, failedOutputPositions, succinctBytes(physicalWrittenDataSize), succinctBytes(failedPhysicalWrittenDataSize), stageGcStatistics.build(), getDynamicFiltersStats(), operatorStatsSummary.build());
}
Also used : BlockedReason(io.trino.operator.BlockedReason) ImmutableList(com.google.common.collect.ImmutableList) Duration(io.airlift.units.Duration) OperatorStats(io.trino.operator.OperatorStats) PlanFragment(io.trino.sql.planner.PlanFragment) BasicQueryStats(io.trino.server.BasicQueryStats) StageGcStatistics(io.trino.spi.eventlistener.StageGcStatistics) HashSet(java.util.HashSet)

Aggregations

StageGcStatistics (io.trino.spi.eventlistener.StageGcStatistics)4 Duration (io.airlift.units.Duration)3 BlockedReason (io.trino.operator.BlockedReason)2 OperatorStats (io.trino.operator.OperatorStats)2 HashSet (java.util.HashSet)2 ImmutableList (com.google.common.collect.ImmutableList)1 QueryInfo (io.trino.execution.QueryInfo)1 QueryStats (io.trino.execution.QueryStats)1 PipelineStats (io.trino.operator.PipelineStats)1 TaskStats (io.trino.operator.TaskStats)1 BasicQueryStats (io.trino.server.BasicQueryStats)1 QueryId (io.trino.spi.QueryId)1 PlanFragment (io.trino.sql.planner.PlanFragment)1 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1 Test (org.testng.annotations.Test)1