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 (2) #39855

Merged
merged 8 commits into from
Jan 29, 2024

Conversation

liuyehcf
Copy link
Contributor

@liuyehcf liuyehcf commented Jan 24, 2024

Why I'm doing:

In the previous pr #33825, we've supported the profile only for big query with the session variable big_query_profile_second_threshold

Unfortunately, for some of our uses, most of the queries can be done within 200ms with a latency spike over 400ms, we cannot catch the slow query(400ms) with the session variable mentioned above.

What I'm doing & Behavior Change

  • Remove session variable big_query_profile_second_threshold with type int.
  • Add session variable big_query_profile_threshold with type string, it can support time duration like 1s/500ms/15m etc.

This change won't lead to compatible problem when performing grey upgrading.

  • Only upgrade some of the backends, it works fine with the previous session variable big_query_profile_second_threshold.
  • Only upgrade all of the backends, it works fine with the previous session variable big_query_profile_second_threshold
  • And after upgrading the frontend, the user need to set up the big_query_profile_threshold corresponding to the previous configuration manually.

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
  • This is a backport pr

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

Signed-off-by: liuyehcf <[email protected]>
@VariableMgr.VarAttr(name = BIG_QUERY_PROFILE_THRESHOLD, alias = BIG_QUERY_PROFILE_SECOND_THRESHOLD)
private long bigQueryProfileThreshold = 0;

@VariableMgr.VarAttr(name = BIG_QUERY_PROFILE_THRESHOLD_UNIT)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add a new big_query_profile_threshold_unit. You can use a string like 1s/1ms/1min and we parse the value and convert to the actual int value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@github-actions github-actions bot added documentation Improvements or additions to documentation behavior_changed labels Jan 25, 2024
Signed-off-by: liuyehcf <[email protected]>
@liuyehcf liuyehcf requested a review from a team as a code owner January 25, 2024 08:02
@chaoyli chaoyli changed the title [Enhancement] Support profile for only big query (2) [Enhancement] Support profile for only big query Jan 25, 2024
chaoyli
chaoyli previously approved these changes Jan 26, 2024
Signed-off-by: liuyehcf <[email protected]>
@@ -16,10 +16,17 @@ SET enable_profile = true;

### 针对慢查询开启 Query Profile

在生产环境中,通常不推荐全面启用 Query Profile 功能。这是因为 Query Profile 的数据采集和处理过程可能会为系统带来额外的负担。然而,如果需要捕捉到耗时的慢查询,就需要巧妙地使用这一功能。为此,您可以选择只对慢查询启用 Query Profile。这可以通过设置变量 `big_query_profile_second_threshold` 为一个大于 `0` 的整数来实现。例如,若将此变量设置为 30,意味着只有那些执行时间超过 30 秒的查询会启用 Query Profile 功能。这样既保证了系统性能,又能有效监控到慢查询。
在生产环境中,通常不推荐全面启用 Query Profile 功能。这是因为 Query Profile 的数据采集和处理过程可能会为系统带来额外的负担。然而,如果需要捕捉到耗时的慢查询,就需要巧妙地使用这一功能。为此,您可以选择只对慢查询启用 Query Profile。这可以通过设置变量 `big_query_profile_threshold` 为一个大于 `0s` 的时间来实现。例如,若将此变量设置为 `30s`,意味着只有那些执行时间超过 30 秒的查询会启用 Query Profile 功能。这样既保证了系统性能,又能有效监控到慢查询。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, is the unit necessary when setting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the type of this variable is string now, a time unit is mandatory.

Copy link

sonarcloud bot commented Jan 26, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

[FE Incremental Coverage Report]

fail : 15 / 34 (44.12%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/qe/ConnectContext.java 0 1 00.00% [597]
🔵 com/starrocks/sql/analyzer/SetStmtAnalyzer.java 1 5 20.00% [257, 258, 259, 260]
🔵 com/starrocks/monitor/unit/TimeValue.java 10 23 43.48% [248, 250, 258, 259, 260, 261, 262, 263, 264, 265, 267, 269, 270]
🔵 com/starrocks/qe/SessionVariable.java 4 5 80.00% [1933]

Copy link

[BE Incremental Coverage Report]

fail : 8 / 24 (33.33%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exec/pipeline/query_context.h 5 21 23.81% [105, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123]
🔵 be/src/exec/pipeline/fragment_executor.cpp 3 3 100.00% []

@liuyehcf liuyehcf changed the title [Enhancement] Support profile for only big query [Enhancement] Support profile for only big query (2) Jan 26, 2024
@Seaven Seaven enabled auto-merge (squash) January 26, 2024 06:56
@kangkaisen kangkaisen merged commit a3758df into StarRocks:main Jan 29, 2024
58 of 61 checks passed
Copy link

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Jan 29, 2024
Copy link

@Mergifyio backport branch-3.1

@github-actions github-actions bot removed the 3.1 label Jan 29, 2024
Copy link
Contributor

mergify bot commented Jan 29, 2024

backport branch-3.2

✅ Backports have been created

Copy link
Contributor

mergify bot commented Jan 29, 2024

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jan 29, 2024
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit a3758df)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/analyzer/SetStmtAnalyzer.java
#	gensrc/thrift/InternalService.thrift
mergify bot pushed a commit that referenced this pull request Jan 29, 2024
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit a3758df)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/analyzer/SetStmtAnalyzer.java
#	gensrc/thrift/InternalService.thrift
ZiheLiu pushed a commit to ZiheLiu/starrocks that referenced this pull request Jan 29, 2024
ZiheLiu pushed a commit to ZiheLiu/starrocks that referenced this pull request Jan 29, 2024
chaoyli pushed a commit to chaoyli/starrocks that referenced this pull request Jan 29, 2024
kangkaisen pushed a commit that referenced this pull request Jan 29, 2024
kangkaisen pushed a commit that referenced this pull request Jan 29, 2024
motto1314 pushed a commit to motto1314/starrocks that referenced this pull request Jan 30, 2024
Seaven pushed a commit to Seaven/starrocks that referenced this pull request Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.1-merged 3.2-merged documentation Improvements or additions to documentation PROTO-REVIEW
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants