Skip to content

[ResourceLimit] Limit CPU resource usage of each query#6443

Merged
yangzhg merged 1 commit intoapache:masterfrom
morningman:scan_thread_num
Aug 27, 2021
Merged

[ResourceLimit] Limit CPU resource usage of each query#6443
yangzhg merged 1 commit intoapache:masterfrom
morningman:scan_thread_num

Conversation

@morningman
Copy link
Contributor

Proposed changes

Details see #6442

I add a new session variable "cpu_resource_limit" and a new user property "cpu_resource_limit".

The default value is -1, which is unlimited. And user can set limit for a single query in a session,
or set the limit for a certain user, so that all queries the user execute will use this limit.

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)
  • Optimization. Including functional usability improvements and performance improvements.
  • Dependency. Such as changes related to third-party components.
  • Other.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have created an issue on (Fix [ResourceLimit] Limit CPU resource usage of each query #6442) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If these changes need document changes, I have updated the document
  • Any dependent changes have been merged

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@morningman morningman added kind/feature Categorizes issue or PR as related to a new feature. resource-limit labels Aug 14, 2021
@morningman morningman changed the title Scan thread num [ResourceLimit] Limit CPU resource usage of each query Aug 14, 2021
// sql block rules
result.add(Lists.newArrayList(PROP_SQL_BLOCK_RULES, commonProperties.getSqlBlockRules()));

// sql block rules
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment is wrong

}

struct TResourceLimit {
1: optional i32 cpu_limit
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe It is better to use a name such as scannode_max_parallelism xxx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to decouple the struct with the certain implementation.
So that we can extend this feature in future.

Copy link
Member

Choose a reason for hiding this comment

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

maybe use max_concurrency is better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe use max_concurrency is better

In fact, what I want to express is that this value is not bound to any implementation. It does not represent the number of threads or the number of concurrency, but a relative value.
It is more like a priority concept, or similar to the concept of weight in cgroups.
In this way, we can continue to use this parameter when we implement more refined resource isolation in the future.

add doc

fix review

fix ut
Copy link
Member

@yangzhg yangzhg left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 25, 2021
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@yangzhg yangzhg merged commit 3f2fdd2 into apache:master Aug 27, 2021
@morningman morningman mentioned this pull request Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. kind/feature Categorizes issue or PR as related to a new feature. resource-limit reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ResourceLimit] Limit CPU resource usage of each query

4 participants