-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[Core] (Resource Isolation 12/n) Switch group killing policy to by time killing policy #62643
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
Changes from 21 commits
a70ff17
b35865a
5c2599f
8245dbb
caf195e
b886146
a7282df
6609b06
7e7031f
c5a67e2
dc8a434
2c14f01
2884c72
e394d33
251a225
83f9f20
4db1afd
2ce6a98
a177a40
4091330
c2655d3
6a99c1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| #include "absl/strings/str_format.h" | ||
| #include "absl/strings/str_join.h" | ||
| #include "ray/common/memory_monitor_interface.h" | ||
| #include "ray/common/ray_config.h" | ||
| #include "ray/util/logging.h" | ||
|
|
||
| namespace ray { | ||
|
|
@@ -292,23 +293,59 @@ int64_t MemoryMonitorUtils::NullableMin(int64_t left, int64_t right) { | |
| } | ||
| } | ||
|
|
||
| int64_t MemoryMonitorUtils::GetMemoryThreshold(int64_t total_memory_bytes, | ||
| float usage_threshold, | ||
| int64_t min_memory_free_bytes) { | ||
| int64_t MemoryMonitorUtils::GetMemoryThreshold( | ||
| int64_t total_memory_bytes, | ||
| float usage_threshold, | ||
| int64_t min_memory_free_bytes, | ||
| bool resource_isolation_enabled, | ||
| const CgroupManagerInterface &cgroup_manager) { | ||
| RAY_CHECK_GE(total_memory_bytes, MemoryMonitorInterface::kNull); | ||
| RAY_CHECK_GE(min_memory_free_bytes, MemoryMonitorInterface::kNull); | ||
| RAY_CHECK_GE(usage_threshold, 0); | ||
| RAY_CHECK_LE(usage_threshold, 1); | ||
| RAY_CHECK_GE(usage_threshold, 0) | ||
| << "Invalid configuration: usage_threshold must be >= 0"; | ||
| RAY_CHECK_LE(usage_threshold, 1) | ||
| << "Invalid configuration: usage_threshold must be <= 1"; | ||
|
|
||
| int64_t threshold_fraction = (int64_t)(total_memory_bytes * usage_threshold); | ||
| int64_t resolved_memory_threshold_bytes; | ||
| int64_t threshold_fraction = static_cast<int64_t>(total_memory_bytes * usage_threshold); | ||
|
|
||
| if (min_memory_free_bytes > MemoryMonitorInterface::kNull) { | ||
| int64_t threshold_absolute = total_memory_bytes - min_memory_free_bytes; | ||
| RAY_CHECK_GE(threshold_absolute, 0); | ||
| return std::max(threshold_fraction, threshold_absolute); | ||
| resolved_memory_threshold_bytes = std::max(threshold_fraction, threshold_absolute); | ||
| } else { | ||
| return threshold_fraction; | ||
| resolved_memory_threshold_bytes = threshold_fraction; | ||
| } | ||
|
|
||
| if (resource_isolation_enabled) { | ||
| StatusOr<std::string> user_memory_max_bytes_or = | ||
| cgroup_manager.GetUserCgroupConstraintValue("memory.max"); | ||
| RAY_CHECK(user_memory_max_bytes_or.ok()) << absl::StrFormat( | ||
| "Failed to get user cgroup memory limit when setting up memory monitor: %s", | ||
| user_memory_max_bytes_or.ToString()); | ||
| std::string user_memory_max_bytes_str = user_memory_max_bytes_or.value(); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When moving the logic from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, the check for whether the string is empty is unnecessary as the underlying call to fetch the constraint value already asserts this. |
||
| if (!user_memory_max_bytes_str.empty() && | ||
| std::all_of(user_memory_max_bytes_str.begin(), | ||
| user_memory_max_bytes_str.end(), | ||
| ::isdigit)) { | ||
|
Kunchd marked this conversation as resolved.
|
||
| int64_t user_memory_max_bytes = std::stoll(user_memory_max_bytes_str); | ||
| int64_t reaction_buffer_bytes = | ||
| std::min(static_cast<int64_t>(total_memory_bytes * | ||
| kDefaultThresholdMonitorReactionBufferProportion), | ||
| RayConfig::instance().max_threshold_monitor_reaction_buffer_bytes()); | ||
| resolved_memory_threshold_bytes = user_memory_max_bytes - reaction_buffer_bytes; | ||
| RAY_CHECK_GE(resolved_memory_threshold_bytes, 0) << absl::StrFormat( | ||
| "Available user task memory is less than the kill memory buffer bytes: " | ||
| "%d < %d. This means the available memory for user proceses is likely " | ||
| "less than 5%% of total memory. Please consider decreasing the proportion " | ||
| "of reserved system memory if it was custom set.", | ||
| user_memory_max_bytes, | ||
| reaction_buffer_bytes); | ||
| } | ||
| } | ||
|
|
||
| return resolved_memory_threshold_bytes; | ||
| } | ||
|
|
||
| int64_t MemoryMonitorUtils::GetProcessUsedMemoryBytes( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying the amount we allocate here so that killing the first actor alone will be guaranteed to relief enough memory pressure without killing a second actor.