Skip to content

Conversation

@kaijchen
Copy link
Member

yiguolei and others added 4 commits November 18, 2024 11:35
…40912)

1. Add memtype to memtable, and save a weak ptr vector in memtable
writer, so that we could get different memory usage by traverse the
vector.
2. Using scoped memory usage to compute the mem usage of a memtable.
3. CHECK if the tracker is 0 when the memtable flush success.

---------

Co-authored-by: yiguolei <yiguolei@gmail.com>
This PR is a followup to change the active memtable flush policy
accordingly.

It also changed:
1. The amount of memtable writers selected in one flush.
2. The memtable writers are selected in orders of its size.
## Proposed changes

Previously, `mem_usage = write_mem + flush_mem`, because `active_mem` is
included in `write_mem`.

After apache#40912, `write_mem` becomes `queue_mem`, which no longer includes
`active_mem`.
This PR fixes this problem, by setting `mem_usage = active_mem +
queue_mem + flush_mem`
…he#41278)

## Proposed changes

apache#41018 used priority queue when selecting memtables to flush.
But the compare function is wrong and causing the order to be the
opposite.

> Note that the Compare parameter is defined such that it
returns true if its first argument comes before its second argument in a
weak ordering. But because the priority queue outputs largest elements
first, the elements that "come before" are actually output last. That
is, the front of the queue contains the "last" element according to the
weak ordering imposed by Compare.

This PR fixes the compare function to make larger memtables come front.
@kaijchen
Copy link
Member Author

run buildall

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

return _mem_tracker->consumption() <= _load_safe_mem_permit;
}

int64_t MemTableMemoryLimiter::_need_flush() {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method '_need_flush' can be made const [readability-make-member-function-const]

be/src/olap/memtable_memory_limiter.h:59:

-     int64_t _need_flush();
+     int64_t _need_flush() const;
Suggested change
int64_t MemTableMemoryLimiter::_need_flush() {
int64_t MemTableMemoryLimiter::_need_flush() const {

@kaijchen kaijchen closed this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants