Skip to content

[Memory] Add a method to get doris current memory usage and Limt memoey usage when consume - #6979

Merged
yangzhg merged 1 commit into
apache:masterfrom
yangzhg:get_current_mem
Nov 24, 2021
Merged

[Memory] Add a method to get doris current memory usage and Limt memoey usage when consume#6979
yangzhg merged 1 commit into
apache:masterfrom
yangzhg:get_current_mem

Conversation

@yangzhg

Copy link
Copy Markdown
Member

Proposed changes

Add a method to get Doris current memory usage, get Doris memory usage every 1 second.
This method used to limit the whole memory allocation in Doris
Add all memory usage check when TryConsume memory

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.

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...

@yangzhgyangzhg changed the title Add a method to get doris current memory usageAdd a method to get doris current memory usage and Limt memoey usage when consumeNov 1, 2021
@yangzhgyangzhg changed the title Add a method to get doris current memory usage and Limt memoey usage when consume[Memory] Add a method to get doris current memory usage and Limt memoey usage when consumeNov 1, 2021
Comment threadbe/src/common/config.h Outdated
Comment threadbe/src/runtime/mem_tracker.h Outdated
@yangzhg
yangzhgforce-pushed the get_current_mem branch 2 times, most recently from d145241 to 39781c6CompareNovember 2, 2021 13:08
@ans76

ans76 commented Nov 2, 2021

Copy link
Copy Markdown

lgtm % add tests for check before allocation?

@yangzhg
yangzhgforce-pushed the get_current_mem branch 2 times, most recently from bec85ac to 6e8b55dCompareNovember 3, 2021 05:12
Comment threadbe/src/util/mem_info.cpp Outdated
Comment threadbe/src/util/mem_info.h Outdated
Comment threadbe/src/runtime/mem_tracker.h Outdated
@yangzhg
yangzhgforce-pushed the get_current_mem branch 3 times, most recently from dc24a76 to cf12d58CompareNovember 10, 2021 02:13
#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && !defined(THREAD_SANITIZER)
doris::MemInfo::refresh_current_mem();
#endif
sleep(10);

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

10ms

if (MemInfo::current_mem() + bytes >= MemInfo::mem_limit()) {
return Status::MemoryLimitExceeded(fmt::format(
"{}: TryConsume failed, bytes={} process whole consumption={} mem limit={}",
label_, bytes, MemInfo::current_mem(), MemInfo::mem_limit()));

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Status::MemoryLimitExceeded not MemTracker::MemLimitExceeded

Add all memory usage check when TryConsume memory

@morningmanmorningman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Nov 23, 2021
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@yangzhg
yangzhg merged commit e2d3d01 into apache:masterNov 24, 2021
@yangzhg
yangzhg deleted the get_current_mem branch February 14, 2022 01:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.area/memory-consumptionkind/improvementreviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@yangzhg@ans76@morningman