use of io.prestosql.spi.eventlistener.StageGcStatistics in project hetu-core by openlookeng.
the class TestBasicQueryInfo method testConstructor.
@Test
public void testConstructor() {
BasicQueryInfo basicInfo = new BasicQueryInfo(new QueryInfo(new QueryId("0"), TEST_SESSION.toSessionRepresentation(), RUNNING, new MemoryPoolId("reserved"), 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"), Duration.valueOf("8m"), Duration.valueOf("7m"), Duration.valueOf("34m"), Duration.valueOf("35m"), Duration.valueOf("44m"), Duration.valueOf("9m"), Duration.valueOf("10m"), Duration.valueOf("11m"), Duration.valueOf("12m"), Duration.valueOf("12m"), Duration.valueOf("12m"), 13, 14, 15, 16, 17, 18, 34, 19, 20.0, DataSize.valueOf("21GB"), DataSize.valueOf("22GB"), DataSize.valueOf("23GB"), DataSize.valueOf("24GB"), DataSize.valueOf("25GB"), DataSize.valueOf("26GB"), DataSize.valueOf("27GB"), DataSize.valueOf("28GB"), DataSize.valueOf("29GB"), true, Duration.valueOf("23m"), Duration.valueOf("24m"), Duration.valueOf("26m"), true, ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY), DataSize.valueOf("271GB"), 281, DataSize.valueOf("272GB"), 282, DataSize.valueOf("27GB"), 28, DataSize.valueOf("29GB"), 30, DataSize.valueOf("31GB"), 32, DataSize.valueOf("32GB"), ImmutableList.of(new StageGcStatistics(101, 102, 103, 104, 105, 106, 107)), 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(), false, Optional.empty(), false));
assertEquals(basicInfo.getQueryId().getId(), "0");
assertEquals(basicInfo.getState(), RUNNING);
assertEquals(basicInfo.getMemoryPool().getId(), "reserved");
assertEquals(basicInfo.isScheduled(), false);
assertEquals(basicInfo.getQuery(), "SELECT 4");
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(), Duration.valueOf("8m"));
assertEquals(basicInfo.getQueryStats().getExecutionTime(), Duration.valueOf("44m"));
assertEquals(basicInfo.getQueryStats().getTotalDrivers(), 16);
assertEquals(basicInfo.getQueryStats().getQueuedDrivers(), 17);
assertEquals(basicInfo.getQueryStats().getRunningDrivers(), 18);
assertEquals(basicInfo.getQueryStats().getCompletedDrivers(), 19);
assertEquals(basicInfo.getQueryStats().getCumulativeUserMemory(), 20.0);
assertEquals(basicInfo.getQueryStats().getUserMemoryReservation(), DataSize.valueOf("21GB"));
assertEquals(basicInfo.getQueryStats().getTotalMemoryReservation(), DataSize.valueOf("23GB"));
assertEquals(basicInfo.getQueryStats().getPeakUserMemoryReservation(), DataSize.valueOf("24GB"));
assertEquals(basicInfo.getQueryStats().getTotalCpuTime(), Duration.valueOf("24m"));
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());
}
use of io.prestosql.spi.eventlistener.StageGcStatistics in project hetu-core by openlookeng.
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(7, NANOSECONDS));
assertEquals(actual.getDistributedPlanningTime(), new Duration(8, NANOSECONDS));
assertEquals(actual.getTotalPlanningTime(), 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.getTotalDrivers(), 12);
assertEquals(actual.getQueuedDrivers(), 13);
assertEquals(actual.getRunningDrivers(), 15);
assertEquals(actual.getBlockedDrivers(), 30);
assertEquals(actual.getCompletedDrivers(), 16);
assertEquals(actual.getCumulativeUserMemory(), 17.0);
assertEquals(actual.getUserMemoryReservation(), new DataSize(18, BYTE));
assertEquals(actual.getRevocableMemoryReservation(), new DataSize(19, BYTE));
assertEquals(actual.getTotalMemoryReservation(), new DataSize(20, BYTE));
assertEquals(actual.getPeakUserMemoryReservation(), new DataSize(21, BYTE));
assertEquals(actual.getPeakRevocableMemoryReservation(), new DataSize(22, BYTE));
assertEquals(actual.getPeakTotalMemoryReservation(), new DataSize(23, BYTE));
assertEquals(actual.getPeakTaskUserMemory(), new DataSize(24, BYTE));
assertEquals(actual.getPeakTaskRevocableMemory(), new DataSize(25, BYTE));
assertEquals(actual.getPeakTaskTotalMemory(), new DataSize(26, BYTE));
assertEquals(actual.getSpilledDataSize(), new DataSize(693, BYTE));
assertEquals(actual.getTotalScheduledTime(), new Duration(20, NANOSECONDS));
assertEquals(actual.getTotalCpuTime(), new Duration(21, NANOSECONDS));
assertEquals(actual.getTotalBlockedTime(), new Duration(23, NANOSECONDS));
assertEquals(actual.getPhysicalInputDataSize(), new DataSize(241, BYTE));
assertEquals(actual.getPhysicalInputPositions(), 251);
assertEquals(actual.getInternalNetworkInputDataSize(), new DataSize(242, BYTE));
assertEquals(actual.getInternalNetworkInputPositions(), 252);
assertEquals(actual.getRawInputDataSize(), new DataSize(24, BYTE));
assertEquals(actual.getRawInputPositions(), 25);
assertEquals(actual.getProcessedInputDataSize(), new DataSize(26, BYTE));
assertEquals(actual.getProcessedInputPositions(), 27);
assertEquals(actual.getOutputDataSize(), new DataSize(28, BYTE));
assertEquals(actual.getOutputPositions(), 29);
assertEquals(actual.getPhysicalWrittenDataSize(), new DataSize(30, BYTE));
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());
}
use of io.prestosql.spi.eventlistener.StageGcStatistics in project hetu-core by openlookeng.
the class StageStateMachine method getStageInfo.
public StageInfo getStageInfo(Supplier<Iterable<TaskInfo>> taskInfosSupplier) {
Optional<StageInfo> localFinalStageInfo = this.finalStageInfo.get();
if (localFinalStageInfo.isPresent()) {
return localFinalStageInfo.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 totalDrivers = 0;
int queuedDrivers = 0;
int runningDrivers = 0;
int blockedDrivers = 0;
int completedDrivers = 0;
long cumulativeUserMemory = 0;
long userMemoryReservation = 0;
long revocableMemoryReservation = 0;
long totalMemoryReservation = 0;
long peakUserMemoryReservation = peakUserMemory.get();
long peakRevocableMemoryReservation = peakRevocableMemory.get();
long totalScheduledTime = 0;
long totalCpuTime = 0;
long totalBlockedTime = 0;
long physicalInputDataSize = 0;
long physicalInputPositions = 0;
long internalNetworkInputDataSize = 0;
long internalNetworkInputPositions = 0;
long rawInputDataSize = 0;
long rawInputPositions = 0;
long processedInputDataSize = 0;
long processedInputPositions = 0;
long bufferedDataSize = 0;
long outputDataSize = 0;
long outputPositions = 0;
long physicalWrittenDataSize = 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++;
}
TaskStats taskStats = taskInfo.getStats();
totalDrivers += taskStats.getTotalDrivers();
queuedDrivers += taskStats.getQueuedDrivers();
runningDrivers += taskStats.getRunningDrivers();
blockedDrivers += taskStats.getBlockedDrivers();
completedDrivers += taskStats.getCompletedDrivers();
cumulativeUserMemory += taskStats.getCumulativeUserMemory();
long taskUserMemory = taskStats.getUserMemoryReservation().toBytes();
long taskSystemMemory = taskStats.getSystemMemoryReservation().toBytes();
long taskRevocableMemory = taskStats.getRevocableMemoryReservation().toBytes();
userMemoryReservation += taskUserMemory;
revocableMemoryReservation += taskRevocableMemory;
totalMemoryReservation += taskUserMemory + taskSystemMemory + taskRevocableMemory;
totalScheduledTime += taskStats.getTotalScheduledTime().roundTo(NANOSECONDS);
totalCpuTime += taskStats.getTotalCpuTime().roundTo(NANOSECONDS);
totalBlockedTime += taskStats.getTotalBlockedTime().roundTo(NANOSECONDS);
if (!taskState.isDone()) {
fullyBlocked &= taskStats.isFullyBlocked();
blockedReasons.addAll(taskStats.getBlockedReasons());
}
physicalInputDataSize += taskStats.getPhysicalInputDataSize().toBytes();
physicalInputPositions += taskStats.getPhysicalInputPositions();
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();
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, totalDrivers, queuedDrivers, runningDrivers, blockedDrivers, completedDrivers, cumulativeUserMemory, succinctBytes(userMemoryReservation), succinctBytes(revocableMemoryReservation), succinctBytes(totalMemoryReservation), succinctBytes(peakUserMemoryReservation), succinctBytes(peakRevocableMemoryReservation), succinctDuration(totalScheduledTime, NANOSECONDS), succinctDuration(totalCpuTime, NANOSECONDS), succinctDuration(totalBlockedTime, NANOSECONDS), fullyBlocked && runningTasks > 0, blockedReasons, succinctBytes(physicalInputDataSize), physicalInputPositions, succinctBytes(internalNetworkInputDataSize), internalNetworkInputPositions, succinctBytes(rawInputDataSize), rawInputPositions, succinctBytes(processedInputDataSize), processedInputPositions, succinctBytes(bufferedDataSize), succinctBytes(outputDataSize), outputPositions, succinctBytes(physicalWrittenDataSize), 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, location, fragment, fragment.getTypes(), stageStats, taskInfos, ImmutableList.of(), tables, failureInfo);
}
use of io.prestosql.spi.eventlistener.StageGcStatistics in project hetu-core by openlookeng.
the class QueryStateMachine method getQueryStats.
private QueryStats getQueryStats(Optional<StageInfo> rootStage) {
int totalTasks = 0;
int runningTasks = 0;
int completedTasks = 0;
int totalDrivers = 0;
int queuedDrivers = 0;
int runningDrivers = 0;
int blockedDrivers = 0;
int completedDrivers = 0;
long cumulativeUserMemory = 0;
long userMemoryReservation = 0;
long revocableMemoryReservation = 0;
long totalMemoryReservation = 0;
long totalScheduledTime = 0;
long totalCpuTime = 0;
long totalBlockedTime = 0;
long physicalInputDataSize = 0;
long physicalInputPositions = 0;
long internalNetworkInputDataSize = 0;
long internalNetworkInputPositions = 0;
long rawInputDataSize = 0;
long rawInputPositions = 0;
long processedInputDataSize = 0;
long processedInputPositions = 0;
long outputDataSize = 0;
long outputPositions = 0;
long physicalWrittenDataSize = 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();
totalDrivers += stageStats.getTotalDrivers();
queuedDrivers += stageStats.getQueuedDrivers();
runningDrivers += stageStats.getRunningDrivers();
blockedDrivers += stageStats.getBlockedDrivers();
completedDrivers += stageStats.getCompletedDrivers();
cumulativeUserMemory += stageStats.getCumulativeUserMemory();
userMemoryReservation += stageStats.getUserMemoryReservation().toBytes();
revocableMemoryReservation += stageStats.getRevocableMemoryReservation().toBytes();
totalMemoryReservation += stageStats.getTotalMemoryReservation().toBytes();
totalScheduledTime += stageStats.getTotalScheduledTime().roundTo(MILLISECONDS);
totalCpuTime += stageStats.getTotalCpuTime().roundTo(MILLISECONDS);
totalBlockedTime += stageStats.getTotalBlockedTime().roundTo(MILLISECONDS);
if (!stageInfo.getState().isDone()) {
fullyBlocked &= stageStats.isFullyBlocked();
blockedReasons.addAll(stageStats.getBlockedReasons());
}
physicalInputDataSize += stageStats.getPhysicalInputDataSize().toBytes();
physicalInputPositions += stageStats.getPhysicalInputPositions();
internalNetworkInputDataSize += stageStats.getInternalNetworkInputDataSize().toBytes();
internalNetworkInputPositions += stageStats.getInternalNetworkInputPositions();
PlanFragment plan = stageInfo.getPlan();
if (plan != null && plan.getPartitionedSourceNodes().stream().anyMatch(TableScanNode.class::isInstance)) {
rawInputDataSize += stageStats.getRawInputDataSize().toBytes();
rawInputPositions += stageStats.getRawInputPositions();
processedInputDataSize += stageStats.getProcessedInputDataSize().toBytes();
processedInputPositions += stageStats.getProcessedInputPositions();
}
physicalWrittenDataSize += stageStats.getPhysicalWrittenDataSize().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();
outputPositions += outputStageStats.getOutputPositions();
}
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.getDistributedPlanningTime(), queryStateTimer.getPlanningTime(), queryStateTimer.getLogicalPlanningTime(), queryStateTimer.getSyntaxAnalysisTime(), queryStateTimer.getFinishingTime(), totalTasks, runningTasks, completedTasks, totalDrivers, queuedDrivers, runningDrivers, blockedDrivers, completedDrivers, cumulativeUserMemory, 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(totalCpuTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), new Duration(totalBlockedTime, MILLISECONDS).convertToMostSuccinctTimeUnit(), fullyBlocked, blockedReasons, succinctBytes(physicalInputDataSize), physicalInputPositions, succinctBytes(internalNetworkInputDataSize), internalNetworkInputPositions, succinctBytes(rawInputDataSize), rawInputPositions, succinctBytes(processedInputDataSize), processedInputPositions, succinctBytes(outputDataSize), outputPositions, succinctBytes(physicalWrittenDataSize), stageGcStatistics.build(), operatorStatsSummary.build());
}
Aggregations