Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;


/**
* SummaryProfile is part of a query profile.
* It contains the summary information of a query.
Expand Down Expand Up @@ -86,6 +87,21 @@ public class SummaryProfile {
public static final String GET_PARTITION_FILES_TIME = "Get Partition Files Time";
public static final String CREATE_SCAN_RANGE_TIME = "Create Scan Range Time";
public static final String SINK_SET_PARTITION_VALUES_TIME = "Sink Set Partition Values Time";
public static final String CPU_SHARE = "CPU Share";
public static final String MEMORY_LIMIT = "Memory Limit";
public static final String MAX_CONCURRENCY = "Max Concurrency";
public static final String MAX_QUEUE_SIZE = "Max Queue Size";
public static final String QUEUE_TIMEOUT = "Queue Timeout";
public static final String CPU_HARD_LIMIT = "Cpu Hard Limit";
public static final String SCAN_THREAD_NUM = "Scan Thread Num";
public static final String MAX_REMOTE_SCAN_THREAD_NUM = "Max Remote Scan Thread Num";
public static final String MIN_REMOTE_SCAN_THREAD_NUM = "Min Remote Scan Thread Num";
public static final String MEMORY_LOW_WATERMARK = "Memory Low Watermark";
public static final String MEMORY_HIGH_WATERMARK = "Memory High Watermark";
public static final String TAG = "Tag";
public static final String READ_BYTES_PER_SECOND = "Read Bytes Per Second";
public static final String REMOTE_READ_BYTES_PER_SECOND = "Remote Read Bytes Per Second";

public static final String PLAN_TIME = "Plan Time";
public static final String SCHEDULE_TIME = "Schedule Time";
public static final String ASSIGN_FRAGMENT_TIME = "Fragment Assign Time";
Expand Down Expand Up @@ -135,6 +151,7 @@ public class SummaryProfile {
public static final String ICEBERG_SCAN_METRICS = "Iceberg Scan Metrics";
public static final String PAIMON_SCAN_METRICS = "Paimon Scan Metrics";


// These info will display on FE's web ui table, every one will be displayed as
// a column, so that should not
// add many columns here. Add to ExecutionSummary list.
Expand All @@ -144,7 +161,6 @@ public class SummaryProfile {
.addAll(SUMMARY_CAPTIONS)
.add(DISTRIBUTED_PLAN)
.build();

// The display order of execution summary items.
public static final ImmutableList<String> EXECUTION_SUMMARY_KEYS = ImmutableList.of(
WORKLOAD_GROUP,
Expand Down Expand Up @@ -199,6 +215,7 @@ public class SummaryProfile {
SPLITS_ASSIGNMENT_WEIGHT
);


// Ident of each item. Default is 0, which doesn't need to present in this Map.
// Please set this map for new profile items if they need ident.
public static ImmutableMap<String, Integer> EXECUTION_SUMMARY_KEYS_INDENTATION
Expand Down Expand Up @@ -243,6 +260,7 @@ public class SummaryProfile {
.put(HMS_UPDATE_PARTITION_CNT, 2)
.build();


@SerializedName(value = "summaryProfile")
private RuntimeProfile summaryProfile = new RuntimeProfile(SUMMARY_PROFILE_NAME);
@SerializedName(value = "executionSummaryProfile")
Expand Down Expand Up @@ -367,6 +385,36 @@ public class SummaryProfile {
private long externalTvfInitTime = 0;
@SerializedName(value = "nereidsPartitiionPruneTime")
private long nereidsPartitiionPruneTime = 0;
@SerializedName(value = "cpuShare")
private int cpuShare = 0;
@SerializedName(value = "memoryLimit")
private double memoryLimit = 0.0;
@SerializedName("enableMemoryOvercommit")
private boolean enableMemoryOvercommit = true;
@SerializedName("maxConcurrency")
private int maxConcurrency = Integer.MAX_VALUE;
@SerializedName("maxQueueSize")
private int maxQueueSize = 0;
@SerializedName("queueTimeout")
private int queueTimeout = 0;
@SerializedName("cpuHardLimit")
private int cpuHardLimit = -1;
@SerializedName("scanThreadNum")
private int scanThreadNum = -1;
@SerializedName("maxRemoteScanThreadNum")
private int maxRemoteScanThreadNum = -1;
@SerializedName("minRemoteScanThreadNum")
private int minRemoteScanThreadNum = -1;
@SerializedName("memoryLowWatermark")
private int memoryLowWatermark = 0;
@SerializedName("memoryHighWatermark")
private int memoryHighWatermark = 0;
@SerializedName("tag")
private String tag = "";
@SerializedName("readBytesPerSecond")
private long readBytesPerSecond = -1L;
@SerializedName("remoteReadBytesPerSecond")
private long remoteReadBytesPerSecond = -1L;
// BE -> (RPC latency from FE to BE, Execution latency on bthread, Duration of doing work, RPC latency from BE
// to FE)
private Map<TNetworkAddress, List<Long>> rpcPhase1Latency;
Expand Down Expand Up @@ -443,13 +491,13 @@ public void queryFinished() {
.sorted(Map.Entry.comparingByValue())
.collect(Collectors.toMap(
entry -> entry.getKey().getAddress(),
Entry::getValue,
Entry::getValue,
(v1, v2) -> v1,
LinkedHashMap::new
LinkedHashMap::new
));
executionSummaryProfile.addInfoString(
SPLITS_ASSIGNMENT_WEIGHT,
new GsonBuilder().create().toJson(m));
new GsonBuilder().create().toJson(m));
}
}

Expand All @@ -465,21 +513,31 @@ private void updateSummaryProfile(Map<String, String> infos) {
}
}

@SuppressWarnings({"checkstyle:LineLength", "checkstyle:Indentation"})
private void updateExecutionSummaryProfile() {
executionSummaryProfile.addInfoString(PARSE_SQL_TIME, getPrettyParseSqlTime());
executionSummaryProfile.addInfoString(PLAN_TIME,
getPrettyTime(queryPlanFinishTime, parseSqlFinishTime, TUnit.TIME_MS));
executionSummaryProfile.addInfoString(NEREIDS_LOCK_TABLE_TIME, getPrettyNereidsLockTableTime());
executionSummaryProfile.addInfoString(NEREIDS_ANALYSIS_TIME, getPrettyNereidsAnalysisTime());
executionSummaryProfile.addInfoString(NEREIDS_REWRITE_TIME, getPrettyNereidsRewriteTime());
executionSummaryProfile.addInfoString(NEREIDS_LOCK_TABLE_TIME,
getPrettyNereidsLockTableTime());
executionSummaryProfile.addInfoString(NEREIDS_ANALYSIS_TIME,
getPrettyNereidsAnalysisTime());
executionSummaryProfile.addInfoString(NEREIDS_REWRITE_TIME,
getPrettyNereidsRewriteTime());
executionSummaryProfile.addInfoString(NEREIDS_COLLECT_TABLE_PARTITION_TIME,
getPrettyNereidsCollectTablePartitionTime());
executionSummaryProfile.addInfoString(NEREIDS_PRE_REWRITE_BY_MV_TIME, getPrettyNereidsPreRewriteByMvTime());
executionSummaryProfile.addInfoString(NEREIDS_OPTIMIZE_TIME, getPrettyNereidsOptimizeTime());
executionSummaryProfile.addInfoString(NEREIDS_TRANSLATE_TIME, getPrettyNereidsTranslateTime());
executionSummaryProfile.addInfoString(NEREIDS_DISTRIBUTE_TIME, getPrettyNereidsDistributeTime());
executionSummaryProfile.addInfoString(NEREIDS_GARBAGE_COLLECT_TIME, getPrettyNereidsGarbageCollectionTime());
executionSummaryProfile.addInfoString(NEREIDS_BE_FOLD_CONST_TIME, getPrettyNereidsBeFoldConstTime());
executionSummaryProfile.addInfoString(NEREIDS_PRE_REWRITE_BY_MV_TIME,
getPrettyNereidsPreRewriteByMvTime());
executionSummaryProfile.addInfoString(NEREIDS_OPTIMIZE_TIME,
getPrettyNereidsOptimizeTime());
executionSummaryProfile.addInfoString(NEREIDS_TRANSLATE_TIME,
getPrettyNereidsTranslateTime());
executionSummaryProfile.addInfoString(NEREIDS_DISTRIBUTE_TIME,
getPrettyNereidsDistributeTime());
executionSummaryProfile.addInfoString(NEREIDS_GARBAGE_COLLECT_TIME,
getPrettyNereidsGarbageCollectionTime());
executionSummaryProfile.addInfoString(NEREIDS_BE_FOLD_CONST_TIME,
getPrettyNereidsBeFoldConstTime());
executionSummaryProfile.addInfoString(INIT_SCAN_NODE_TIME,
getPrettyTime(initScanNodeFinishTime, initScanNodeStartTime, TUnit.TIME_MS));
executionSummaryProfile.addInfoString(FINALIZE_SCAN_NODE_TIME,
Expand Down Expand Up @@ -514,6 +572,28 @@ private void updateExecutionSummaryProfile() {
RuntimeProfile.printCounter(queryFetchResultConsumeTime, TUnit.TIME_MS));
executionSummaryProfile.addInfoString(WRITE_RESULT_TIME,
RuntimeProfile.printCounter(queryWriteResultConsumeTime, TUnit.TIME_MS));
executionSummaryProfile.addInfoString(CPU_SHARE,
RuntimeProfile.printCounter(cpuShare, TUnit.UNIT));
executionSummaryProfile.addInfoString(CPU_HARD_LIMIT,
RuntimeProfile.printCounter(cpuHardLimit, TUnit.NONE));
executionSummaryProfile.addInfoString(MEMORY_LIMIT, memoryLimit + "%");
executionSummaryProfile.addInfoString(MEMORY_LOW_WATERMARK, memoryLowWatermark + "%");
executionSummaryProfile.addInfoString(MEMORY_HIGH_WATERMARK, memoryHighWatermark + "%");
executionSummaryProfile.addInfoString(MAX_CONCURRENCY,
RuntimeProfile.printCounter(maxConcurrency, TUnit.NONE));
executionSummaryProfile.addInfoString(MAX_QUEUE_SIZE, RuntimeProfile.printCounter(maxQueueSize, TUnit.NONE));
executionSummaryProfile.addInfoString(QUEUE_TIMEOUT, RuntimeProfile.printCounter(queueTimeout, TUnit.TIME_MS));
executionSummaryProfile.addInfoString(SCAN_THREAD_NUM,
RuntimeProfile.printCounter(scanThreadNum, TUnit.NONE));
executionSummaryProfile.addInfoString(MAX_REMOTE_SCAN_THREAD_NUM,
RuntimeProfile.printCounter(maxRemoteScanThreadNum, TUnit.NONE));
executionSummaryProfile.addInfoString(MIN_REMOTE_SCAN_THREAD_NUM,
RuntimeProfile.printCounter(minRemoteScanThreadNum, TUnit.NONE));
executionSummaryProfile.addInfoString(TAG, tag);
executionSummaryProfile.addInfoString(READ_BYTES_PER_SECOND,
RuntimeProfile.printCounter(readBytesPerSecond, TUnit.BYTES_PER_SECOND));
executionSummaryProfile.addInfoString(REMOTE_READ_BYTES_PER_SECOND,
RuntimeProfile.printCounter(remoteReadBytesPerSecond, TUnit.BYTES_PER_SECOND));
setTransactionSummary();

if (Config.isCloudMode()) {
Expand Down Expand Up @@ -730,6 +810,64 @@ public void setRpcPhase2Latency(Map<TNetworkAddress, List<Long>> rpcPhase2Latenc
this.rpcPhase2Latency = rpcPhase2Latency;
}

public void setCpuShare(int cpuShare) {
this.cpuShare = cpuShare;
}


public void setMemoryLimit(double memoryLimit) {
this.memoryLimit = memoryLimit;
}


public void setMaxConcurrency(int maxConcurrency) {
this.maxConcurrency = maxConcurrency;
}

public void setMaxQueueSize(int maxQueueSize) {
this.maxQueueSize = maxQueueSize;
}

public void setQueueTimeout(int queueTimeout) {
this.queueTimeout = queueTimeout;
}

public void setCpuHardLimit(int cpuHardLimit) {
this.cpuHardLimit = cpuHardLimit;
}

public void setScanThreadNum(int scanThreadNum) {
this.scanThreadNum = scanThreadNum;
}

public void setMaxRemoteScanThreadNum(int maxRemoteScanThreadNum) {
this.maxRemoteScanThreadNum = maxRemoteScanThreadNum;
}

public void setMinRemoteScanThreadNum(int minRemoteScanThreadNum) {
this.minRemoteScanThreadNum = minRemoteScanThreadNum;
}

public void setMemoryLowWatermark(int memoryLowWatermark) {
this.memoryLowWatermark = memoryLowWatermark;
}

public void setMemoryHighWatermark(int memoryHighWatermark) {
this.memoryHighWatermark = memoryHighWatermark;
}

public void setTag(String tag) {
this.tag = tag;
}

public void setReadBytesPerSecond(long readBytesPerSecond) {
this.readBytesPerSecond = readBytesPerSecond;
}

public void setRemoteReadBytesPerSecond(long remoteReadBytesPerSecond) {
this.remoteReadBytesPerSecond = remoteReadBytesPerSecond;
}

public static class SummaryBuilder {
private Map<String, String> map = Maps.newHashMap();

Expand Down Expand Up @@ -850,7 +988,7 @@ public int getNereidsRewriteTimeMs() {

public int getNereidsCollectTablePartitionTimeMs() {
return getTimeMs(nereidsCollectTablePartitionFinishTime, nereidsRewriteFinishTime)
+ (int) nereidsCollectTablePartitionTime;
+ (int) nereidsCollectTablePartitionTime;
}

public int getNereidsOptimizeTimeMs() {
Expand Down Expand Up @@ -1188,43 +1326,61 @@ public static SummaryProfile getSummaryProfile(ConnectContext connectContext) {
}

public String getPlanTime() {
String planTimesMs = "{"
+ "\"plan\"" + ":" + this.getPlanTimeMs() + ","
+ "\"garbage_collect\"" + ":" + this.getNereidsGarbageCollectionTimeMs() + ","
+ "\"lock_tables\"" + ":" + this.getNereidsLockTableTimeMs() + ","
+ "\"analyze\"" + ":" + this.getNereidsAnalysisTimeMs() + ","
+ "\"rewrite\"" + ":" + this.getNereidsRewriteTimeMs() + ","
+ "\"fold_const_by_be\"" + ":" + this.getNereidsBeFoldConstTimeMs() + ","
+ "\"collect_partitions\"" + ":" + this.getNereidsCollectTablePartitionTimeMs() + ","
+ "\"optimize\"" + ":" + this.getNereidsOptimizeTimeMs() + ","
+ "\"translate\"" + ":" + this.getNereidsTranslateTimeMs() + ","
+ "\"init_scan_node\"" + ":" + this.getInitScanNodeTimeMs() + ","
+ "\"finalize_scan_node\"" + ":" + this.getFinalizeScanNodeTimeMs() + ","
+ "\"create_scan_range\"" + ":" + this.getCreateScanRangeTimeMs() + ","
+ "\"distribute\"" + ":" + this.getNereidsDistributeTimeMs()
+ "}";
String planTimesMs = "{" + "\"plan\"" + ":" + this.getPlanTimeMs() + "," + "\"garbage_collect\"" + ":"
+ this.getNereidsGarbageCollectionTimeMs() + ","
+ "\"lock_tables\""
+ ":"
+ this.getNereidsLockTableTimeMs()
+ "," + "\"analyze\""
+ ":" + this.getNereidsAnalysisTimeMs()
+ "," + "\"rewrite\""
+ ":"
+ this.getNereidsRewriteTimeMs()
+ "," + "\"fold_const_by_be\""
+ ":" + this.getNereidsBeFoldConstTimeMs()
+ "," + "\"collect_partitions\""
+ ":"
+ this.getNereidsCollectTablePartitionTimeMs()
+ "," + "\"optimize\""
+ ":" + this.getNereidsOptimizeTimeMs()
+ "," + "\"translate\""
+ ":" + this.getNereidsTranslateTimeMs()
+ "," + "\"init_scan_node\""
+ ":" + this.getInitScanNodeTimeMs()
+ "," + "\"finalize_scan_node\"" + ":"
+ this.getFinalizeScanNodeTimeMs()
+ "," + "\"create_scan_range\""
+ ":" + this.getCreateScanRangeTimeMs()
+ "," + "\"distribute\"" + ":" + this.getNereidsDistributeTimeMs() + "}";
return planTimesMs;
}

public String getMetaTime() {
return "{"
+ "\"get_partition_version_time_ms\"" + ":" + this.getGetPartitionVersionTime() + ","
+ "\"get_partition_version_count_has_data\"" + ":" + this.getGetPartitionVersionByHasDataCount() + ","
+ "\"get_partition_version_count\"" + ":" + this.getGetPartitionVersionCount() + ","
+ "\"get_table_version_time_ms\"" + ":" + this.getGetTableVersionTime() + ","
+ "\"get_table_version_count\"" + ":" + this.getGetTableVersionCount()
+ "}";
return "{" + "\"get_partition_version_time_ms\""
+ ":" + this.getGetPartitionVersionTime()
+ "," + "\"get_partition_version_count_has_data\""
+ ":" + this.getGetPartitionVersionByHasDataCount()
+ "," + "\"get_partition_version_count\""
+ ":" + this.getGetPartitionVersionCount()
+ "," + "\"get_table_version_time_ms\""
+ ":" + this.getGetTableVersionTime()
+ "," + "\"get_table_version_count\""
+ ":" + this.getGetTableVersionCount() + "}";
}

public String getScheduleTime() {
return "{"
+ "\"schedule_time_ms\"" + ":" + this.getScheduleTimeMs() + ","
+ "\"fragment_assign_time_ms\"" + ":" + this.getFragmentAssignTimsMs() + ","
+ "\"fragment_serialize_time_ms\"" + ":" + this.getFragmentSerializeTimeMs() + ","
+ "\"fragment_rpc_phase_1_time_ms\"" + ":" + this.getFragmentRPCPhase1TimeMs() + ","
+ "\"fragment_rpc_phase_2_time_ms\"" + ":" + this.getFragmentRPCPhase2TimeMs() + ","
+ "\"fragment_compressed_size_byte\"" + ":" + this.getFragmentCompressedSizeByte() + ","
+ "\"fragment_rpc_count\"" + ":" + this.getFragmentRPCCount()
+ "}";
return "{" + "\"schedule_time_ms\""
+ ":" + this.getScheduleTimeMs()
+ "," + "\"fragment_assign_time_ms\""
+ ":" + this.getFragmentAssignTimsMs()
+ "," + "\"fragment_serialize_time_ms\""
+ ":" + this.getFragmentSerializeTimeMs()
+ "," + "\"fragment_rpc_phase_1_time_ms\""
+ ":" + this.getFragmentRPCPhase1TimeMs()
+ "," + "\"fragment_rpc_phase_2_time_ms\""
+ ":" + this.getFragmentRPCPhase2TimeMs()
+ "," + "\"fragment_compressed_size_byte\""
+ ":" + this.getFragmentCompressedSizeByte()
+ "," + "\"fragment_rpc_count\"" + ":" + this.getFragmentRPCCount() + "}";
}
}
Loading
Loading