Skip to content
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

[Core] Make Object Store memory default ratio env-configurable #47726

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions python/ray/_private/ray_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ def env_set_by_user(key):

# The default maximum number of bytes to allocate to the object store unless
# overridden by the user.
DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES = 200 * 10**9
alexeykudinkin marked this conversation as resolved.
Show resolved Hide resolved
DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES = env_integer(
"RAY_DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES", 200 * 10**9 # 200 GB
)
# The default proportion of available memory allocated to the object store
DEFAULT_OBJECT_STORE_MEMORY_PROPORTION = 0.3
DEFAULT_OBJECT_STORE_MEMORY_PROPORTION = env_float(
"RAY_DEFAULT_OBJECT_STORE_MEMORY_PROPORTION", 0.3
)
# The smallest cap on the memory used by the object store that we allow.
# This must be greater than MEMORY_RESOURCE_UNIT_BYTES
OBJECT_STORE_MINIMUM_MEMORY_BYTES = 75 * 1024 * 1024
Expand Down
21 changes: 14 additions & 7 deletions python/ray/_private/resource_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,33 @@ def resolve(self, is_head: bool, node_ip_address: Optional[str] = None):
object_store_memory, ray_constants.MAC_DEGRADED_PERF_MMAP_SIZE_LIMIT
)

max_cap = ray_constants.DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES
object_store_memory_cap = (
ray_constants.DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES
)

# Cap by shm size by default to avoid low performance, but don't
# go lower than REQUIRE_SHM_SIZE_THRESHOLD.
if sys.platform == "linux" or sys.platform == "linux2":
# Multiple by 0.95 to give a bit of wiggle-room.
# https://github.com/ray-project/ray/pull/23034/files
shm_avail = ray._private.utils.get_shared_memory_bytes() * 0.95
max_cap = min(
max(ray_constants.REQUIRE_SHM_SIZE_THRESHOLD, shm_avail), max_cap
)
shm_cap = max(ray_constants.REQUIRE_SHM_SIZE_THRESHOLD, shm_avail)

object_store_memory_cap = min(object_store_memory_cap, shm_cap)

# Cap memory to avoid memory waste and perf issues on large nodes
if object_store_memory > max_cap:
if (
object_store_memory_cap
and object_store_memory > object_store_memory_cap
):
logger.debug(
"Warning: Capping object memory store to {}GB. ".format(
max_cap // 1e9
object_store_memory_cap // 1e9
)
+ "To increase this further, specify `object_store_memory` "
"when calling ray.init() or ray start."
)
object_store_memory = max_cap
object_store_memory = object_store_memory_cap

redis_max_memory = self.redis_max_memory
if redis_max_memory is None:
Expand Down
2 changes: 1 addition & 1 deletion python/ray/autoscaler/_private/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

import click

from ray._private.ray_constants import DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES
from ray.autoscaler._private.cli_logger import cf, cli_logger
from ray.autoscaler._private.constants import (
AUTOSCALER_NODE_SSH_INTERVAL_S,
AUTOSCALER_NODE_START_WAIT_S,
DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES,
DEFAULT_OBJECT_STORE_MEMORY_PROPORTION,
)
from ray.autoscaler._private.docker import (
Expand Down
1 change: 0 additions & 1 deletion python/ray/autoscaler/_private/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from ray._private.ray_constants import ( # noqa F401
AUTOSCALER_RESOURCE_REQUEST_CHANNEL,
DEFAULT_OBJECT_STORE_MAX_MEMORY_BYTES,
DEFAULT_OBJECT_STORE_MEMORY_PROPORTION,
LABELS_ENVIRONMENT_VARIABLE,
LOGGER_FORMAT,
Expand Down