Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support profile for only big query #33825

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

liuyehcf
Copy link
Contributor

@liuyehcf liuyehcf commented Oct 27, 2023

Background

In practical system, we won't enable the profile, because this feature may have significant overhead and may lead to decrease in performance. But some slow query may occur on a regular basis, and we want to get the profile of those queries, which is not supported in our system currently.

How

In this pr, we offer an additional session variable, namely big_query_profile_second_threshold, to enable only the slow query.

And here's how it works:

  • if enable_profile=true, than the added variable is simply ignored.
  • If enable_profile=false and big_query_profile_second_threshold > 0. Backend will process profile and report profile if overall time exceed the threshold(defined by big_query_profile_second_threshold). And frontend will finally decide whether the profile will be displayed or not based on the comparation between the overall query time and big_query_profile_second_threshold, if the overall query time is greater then the value of big_query_profile_second_threshold, the profile can be seen, otherwise not.

Limitation

A large query might consist of several fragment instances. Some of these instances finish quickly after execution starts, while others may take several minutes. Only those fragment instances that last longer than the bigQueryProfileSecondThreshold will report their profiles. This results in an incomplete profile that includes only the most time-consuming parts

Example

https://gist.github.com/liuyehcf/a4ec577d188622cf16d324d0491e6e69

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@liuyehcf liuyehcf changed the title [Enhancement] Support profile only for long-running profile [Enhancement] Support profile for only big query Oct 30, 2023
@liuyehcf liuyehcf force-pushed the profile branch 2 times, most recently from 7dd9145 to 7c81810 Compare October 30, 2023 09:08
Signed-off-by: liuyehcf <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Oct 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@github-actions
Copy link

[FE Incremental Coverage Report]

fail : 21 / 30 (70.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/load/loadv2/LoadLoadingTask.java 0 1 00.00% [220]
🔵 com/starrocks/load/streamload/StreamLoadTask.java 0 1 00.00% [1061]
🔵 com/starrocks/qe/StmtExecutor.java 2 4 50.00% [793, 802]
🔵 com/starrocks/qe/scheduler/QueryRuntimeProfile.java 2 3 66.67% [277]
🔵 com/starrocks/qe/ConnectContext.java 7 10 70.00% [563, 571, 572]
🔵 com/starrocks/qe/SessionVariable.java 3 4 75.00% [1665]
🔵 com/starrocks/common/profile/Tracers.java 2 2 100.00% []
🔵 com/starrocks/qe/scheduler/dag/JobSpec.java 2 2 100.00% []
🔵 com/starrocks/qe/DefaultCoordinator.java 3 3 100.00% []

@github-actions
Copy link

[BE Incremental Coverage Report]

fail : 4 / 10 (40.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 src/exec/pipeline/fragment_executor.cpp 0 2 00.00% [138, 139]
🔵 src/exec/pipeline/query_context.h 4 8 50.00% [94, 99, 101, 102]

@liuyehcf liuyehcf enabled auto-merge (squash) October 30, 2023 11:34
@kangkaisen kangkaisen merged commit 0e2d056 into StarRocks:main Oct 30, 2023
50 of 52 checks passed
@github-actions
Copy link

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Oct 30, 2023
@github-actions
Copy link

@Mergifyio backport branch-3.1

@mergify
Copy link
Contributor

mergify bot commented Oct 30, 2023

backport branch-3.2

✅ Backports have been created

@github-actions github-actions bot removed the 3.1 label Oct 30, 2023
mergify bot pushed a commit that referenced this pull request Oct 30, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	gensrc/thrift/InternalService.thrift
@mergify
Copy link
Contributor

mergify bot commented Oct 30, 2023

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 30, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/common/profile/Tracers.java
#	fe/fe-core/src/main/java/com/starrocks/qe/DefaultCoordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/Coordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/QueryRuntimeProfile.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/JobSpec.java
#	gensrc/thrift/InternalService.thrift
wanpengfei-git pushed a commit that referenced this pull request Oct 30, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	gensrc/thrift/InternalService.thrift
wanpengfei-git pushed a commit that referenced this pull request Oct 31, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/common/profile/Tracers.java
#	fe/fe-core/src/main/java/com/starrocks/qe/DefaultCoordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/Coordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/QueryRuntimeProfile.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/JobSpec.java
#	gensrc/thrift/InternalService.thrift
@liuyehcf
Copy link
Contributor Author

@Mergifyio backport branch-2.5

@mergify
Copy link
Contributor

mergify bot commented Oct 31, 2023

backport branch-2.5

✅ Backports have been created

@liuyehcf
Copy link
Contributor Author

@Mergifyio backport branch-3.0

@mergify
Copy link
Contributor

mergify bot commented Oct 31, 2023

backport branch-3.0

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 31, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	be/src/exec/pipeline/query_context.h
#	fe/fe-core/src/main/java/com/starrocks/common/profile/Tracers.java
#	fe/fe-core/src/main/java/com/starrocks/load/loadv2/LoadLoadingTask.java
#	fe/fe-core/src/main/java/com/starrocks/load/streamload/StreamLoadTask.java
#	fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java
#	fe/fe-core/src/main/java/com/starrocks/qe/DefaultCoordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/Coordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/QueryRuntimeProfile.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/JobSpec.java
#	gensrc/thrift/InternalService.thrift
mergify bot pushed a commit that referenced this pull request Oct 31, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	be/src/exec/pipeline/query_context.h
#	fe/fe-core/src/main/java/com/starrocks/common/profile/Tracers.java
#	fe/fe-core/src/main/java/com/starrocks/load/loadv2/LoadLoadingTask.java
#	fe/fe-core/src/main/java/com/starrocks/load/streamload/StreamLoadTask.java
#	fe/fe-core/src/main/java/com/starrocks/qe/DefaultCoordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/Coordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/QueryRuntimeProfile.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/JobSpec.java
#	gensrc/thrift/InternalService.thrift
wanpengfei-git pushed a commit that referenced this pull request Oct 31, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	be/src/exec/pipeline/query_context.h
#	fe/fe-core/src/main/java/com/starrocks/common/profile/Tracers.java
#	fe/fe-core/src/main/java/com/starrocks/load/loadv2/LoadLoadingTask.java
#	fe/fe-core/src/main/java/com/starrocks/load/streamload/StreamLoadTask.java
#	fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java
#	fe/fe-core/src/main/java/com/starrocks/qe/DefaultCoordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/Coordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/QueryRuntimeProfile.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/JobSpec.java
#	gensrc/thrift/InternalService.thrift
wanpengfei-git pushed a commit that referenced this pull request Oct 31, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 0e2d056)

# Conflicts:
#	be/src/exec/pipeline/query_context.h
#	fe/fe-core/src/main/java/com/starrocks/common/profile/Tracers.java
#	fe/fe-core/src/main/java/com/starrocks/load/loadv2/LoadLoadingTask.java
#	fe/fe-core/src/main/java/com/starrocks/load/streamload/StreamLoadTask.java
#	fe/fe-core/src/main/java/com/starrocks/qe/DefaultCoordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/Coordinator.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/QueryRuntimeProfile.java
#	fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/JobSpec.java
#	gensrc/thrift/InternalService.thrift
liuyehcf added a commit to liuyehcf/starrocks that referenced this pull request Nov 1, 2023
liuyehcf added a commit to liuyehcf/starrocks that referenced this pull request Nov 1, 2023
@liuyehcf
Copy link
Contributor Author

liuyehcf commented Dec 14, 2023

version >=3.0.8 or >=3.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants