kubewharf / katalyst-core

Katalyst aims to provide a universal solution to help improve resource utilization and optimize the overall costs in the cloud. This is the core components in Katalyst system, including multiple agents and centralized components
Apache License 2.0
394 stars 91 forks source link

refactor(sysadvisor): refine memory guard #499

Closed cheney-lin closed 3 months ago

cheney-lin commented 4 months ago

What type of PR is this?

Enhancements

What this PR does / why we need it:

The current memory protection mechanism is achieved by setting the memory limit of the Besteffort group to avoid memory overflows. However, when calculating the limit, the cache of high-priority services is considered as reclaimable, so that direct memory reclamation can still be triggered when memory bursting. This MR refactors the calculation logic. Firstly, we calculates the safety memory upper limit for each available NUMA node, and then sums them up to obtain the result. The upper limit for each NUMA node is calculated as followed: NUMA free memory + Besteffort group memory used on the NUMA node - reserved memory.

Which issue(s) this PR fixes:

Special notes for your reviewer:

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 65.38462% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 55.54%. Comparing base (21c243d) to head (431175e).

Files Patch % Lines
.../agent/metric/provisioner/malachite/provisioner.go 0.00% 10 Missing :warning:
...in/qosaware/resource/memory/plugin/memory_guard.go 80.00% 5 Missing and 2 partials :warning:
pkg/metaserver/agent/metric/metric_impl.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #499 +/- ## ========================================== + Coverage 55.47% 55.54% +0.06% ========================================== Files 552 552 Lines 59419 59419 ========================================== + Hits 32965 33005 +40 + Misses 23022 22986 -36 + Partials 3432 3428 -4 ``` | [Flag](https://app.codecov.io/gh/kubewharf/katalyst-core/pull/499/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubewharf) | Coverage Δ | | |---|---|---| | [unittest](https://app.codecov.io/gh/kubewharf/katalyst-core/pull/499/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubewharf) | `55.54% <65.38%> (+0.06%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubewharf#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.