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] adjust async-profile queue strategy #52236

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

murphyatwork
Copy link
Contributor

@murphyatwork murphyatwork commented Oct 23, 2024

Why I'm doing:

Async profile uses a background threadpool to process profile, but it's configuration doesn't make sense for some intensive workload.

  • thread_num: default is 2
  • queue_size: thread_num * 128, too large
  • The unmerged profile can be pretty large(2 digits MB), including the query-plan and a lot of counters in it

For a typical workload:

  • Each profile task would take over 200ms, and the peak QPS is 100
  • For this workload, it needs at least 100 / (1/0.2)=20 threads to catchup the query profile
  • If the profile-worker is unable to catchup the queue, the query profile would be accumulated and take a lot of memory

What I'm doing:

Change the threadpool of profile-worker:

  1. thread_num: max as cpu_cores*0.75
  2. queue_size: max as thread_num*4

For the above workload:

  1. If FE has 64 cpu_cores, the thread_num would be 48, which is enough

Fixes #issue

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.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@murphyatwork murphyatwork requested a review from a team as a code owner October 23, 2024 06:34
Signed-off-by: Murphy <mofei@starrocks.com>
Copy link

sonarcloud bot commented Oct 23, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@github-actions github-actions bot removed the 3.2 label Oct 23, 2024
Seaven
Seaven previously approved these changes Oct 23, 2024
Signed-off-by: Murphy <mofei@starrocks.com>
Signed-off-by: Murphy <mofei@starrocks.com>
Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 6 / 6 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/qe/scheduler/QueryRuntimeProfile.java 4 4 100.00% []
🔵 com/starrocks/common/ThreadPoolManager.java 2 2 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

*/
private static final ThreadPoolExecutor EXECUTOR =
ThreadPoolManager.newDaemonFixedThreadPool(Config.profile_process_threads_num,
Integer.MAX_VALUE, "profile-worker", false);
ThreadPoolManager.newDaemonCacheThreadPool(
Copy link
Contributor

Choose a reason for hiding this comment

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

so thread pool core size is 3/4 * all cpus, maximumPoolSize is 3 * All cpus? can you explain why you decide using these numbers

@@ -256,7 +258,7 @@ public boolean isFinished() {
}

public boolean addListener(Consumer<Boolean> task) {
if (EXECUTOR.getQueue().size() > Config.profile_process_blocking_queue_size) {
if (EXECUTOR.getQueue().remainingCapacity() <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so only 'corePoolSize' threads will be created? because when queue is full ,we change to sync profile mode

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.

3 participants