Skip to content
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
4 changes: 1 addition & 3 deletions python/ray/_private/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ def propagate_jemalloc_env_var(
if not jemalloc_path:
return {}

env_vars = {
"LD_PRELOAD": jemalloc_path,
}
env_vars = {"LD_PRELOAD": jemalloc_path, "RAY_LD_PRELOAD": "1"}
if process_type in jemalloc_comps and jemalloc_conf:
env_vars.update({"MALLOC_CONF": jemalloc_conf})
return env_vars
Expand Down
8 changes: 6 additions & 2 deletions python/ray/tests/test_advanced_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_jemalloc_env_var_propagate():
When the shared library is specified
"""
library_path = "/abc"
expected = {"LD_PRELOAD": library_path}
expected = {"LD_PRELOAD": library_path, "RAY_LD_PRELOAD": "1"}
actual = ray._private.services.propagate_jemalloc_env_var(
jemalloc_path=library_path,
jemalloc_conf="",
Expand Down Expand Up @@ -100,7 +100,11 @@ def test_jemalloc_env_var_propagate():
"""
library_path = "/abc"
malloc_conf = "a,b,c"
expected = {"LD_PRELOAD": library_path, "MALLOC_CONF": malloc_conf}
expected = {
"LD_PRELOAD": library_path,
"MALLOC_CONF": malloc_conf,
"RAY_LD_PRELOAD": "1",
}
actual = ray._private.services.propagate_jemalloc_env_var(
jemalloc_path=library_path,
jemalloc_conf=malloc_conf,
Expand Down
2 changes: 1 addition & 1 deletion python/ray/tests/test_basic_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def check_jemalloc_enabled(pid=None):
assert check_jemalloc_enabled(
node.all_processes[ray_constants.PROCESS_TYPE_RAYLET][0].process.pid
)
assert ray.get(ray.remote(check_jemalloc_enabled).remote())
assert not ray.get(ray.remote(check_jemalloc_enabled).remote())

ray.shutdown()
cluster.shutdown()
Expand Down
11 changes: 11 additions & 0 deletions src/ray/raylet/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include <iostream>

#ifdef __linux__
#include <stdlib.h>
#endif

#include "gflags/gflags.h"
#include "nlohmann/json.hpp"
#include "ray/common/asio/instrumented_io_context.h"
Expand Down Expand Up @@ -122,6 +126,13 @@ int main(int argc, char *argv[]) {
ray::RayLog::InstallTerminateHandler();

gflags::ParseCommandLineFlags(&argc, &argv, true);
#ifdef __linux__
// Reset LD_PRELOAD if it's loaded with ray jemalloc
auto ray_ld_preload = std::getenv("RAY_LD_PRELOAD");
if (ray_ld_preload != nullptr && std::string(ray_ld_preload) == "1") {
unsetenv("LD_PRELOAD");
}
#endif
const std::string raylet_socket_name = FLAGS_raylet_socket_name;
const std::string store_socket_name = FLAGS_store_socket_name;
const std::string node_name =
Expand Down