mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
reset memory for tasks and actors to 5% when cached memory added (#14345)
This commit is contained in:
parent
26907b7708
commit
6f151ad510
1 changed files with 20 additions and 1 deletions
|
@ -409,6 +409,21 @@ def get_system_memory():
|
|||
return psutil_memory_in_bytes
|
||||
|
||||
|
||||
def get_cached_memory():
|
||||
"""Return the currently cached memory in bytes
|
||||
|
||||
Returns:
|
||||
The total amount of cached memory
|
||||
"""
|
||||
# Try to accurately figure out the cached memory.
|
||||
psutil_virtual_memory = psutil.virtual_memory()
|
||||
psutil_cached_memory_in_bytes = 0
|
||||
if hasattr(psutil_virtual_memory, "cached"):
|
||||
psutil_cached_memory_in_bytes = psutil_virtual_memory.cached
|
||||
|
||||
return psutil_cached_memory_in_bytes
|
||||
|
||||
|
||||
def _get_docker_cpus(
|
||||
cpu_quota_file_name="/sys/fs/cgroup/cpu/cpu.cfs_quota_us",
|
||||
cpu_share_file_name="/sys/fs/cgroup/cpu/cpu.cfs_period_us",
|
||||
|
@ -536,7 +551,11 @@ def estimate_available_memory():
|
|||
and total memory.
|
||||
|
||||
"""
|
||||
return get_system_memory() - get_used_memory()
|
||||
# Linux, BSD has cached memory, which should
|
||||
# also be considered as unused memory
|
||||
# consider half of cached memory can be recycled.
|
||||
# https://gitlab.com/procps-ng/procps/-/blob/master/proc/sysinfo.c#L805
|
||||
return get_system_memory() - get_used_memory() + get_cached_memory() / 2
|
||||
|
||||
|
||||
def get_shared_memory_bytes():
|
||||
|
|
Loading…
Add table
Reference in a new issue