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

Hjiang/test env benchmark 3 #49761

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion release/benchmarks/distributed/test_many_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def test_max_running_tasks(num_tasks):
cpus_per_task = 0.25

@ray.remote(num_cpus=cpus_per_task)
@ray.remote(num_cpus=cpus_per_task, runtime_env={"env_vars": {"FOO": "bar"}})
def task():
time.sleep(sleep_time)

Expand Down
30 changes: 30 additions & 0 deletions src/ray/raylet/worker_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1730,10 +1730,33 @@ WorkerPool::IOWorkerState &WorkerPool::GetIOWorkerStateFromWorkerType(
UNREACHABLE;
}

static std::mutex runtime_env_setup_mutex;
static std::optional<std::string> serialized_runtime_env_context_cache;

void WorkerPool::GetOrCreateRuntimeEnv(const std::string &serialized_runtime_env,
const rpc::RuntimeEnvConfig &runtime_env_config,
const JobID &job_id,
const GetOrCreateRuntimeEnvCallback &callback) {
if (serialized_runtime_env.find("FOO") != std::string::npos) {
bool directly_call_callback = false;
std::string serialized_result = "";
{
const std::lock_guard lck(runtime_env_setup_mutex);
if (serialized_runtime_env_context_cache.has_value()) {
directly_call_callback = true;
serialized_result = *serialized_runtime_env_context_cache;
}
}
if (directly_call_callback) {
io_service_->post(
[callback, serialized_result = std::move(serialized_result)]() {
callback(true, serialized_result, "");
},
"WorkerPool.GetOrCreateRuntimeEnvCallback");
return;
}
}

RAY_LOG(DEBUG) << "GetOrCreateRuntimeEnv for job " << job_id << " with runtime_env "
<< serialized_runtime_env;
runtime_env_agent_client_->GetOrCreateRuntimeEnv(
Expand All @@ -1745,6 +1768,11 @@ void WorkerPool::GetOrCreateRuntimeEnv(const std::string &serialized_runtime_env
const std::string &serialized_runtime_env_context,
const std::string &setup_error_message) {
if (successful) {
if (serialized_runtime_env.find("FOO") != std::string::npos) {
const std::lock_guard lck(runtime_env_setup_mutex);
serialized_runtime_env_context_cache = serialized_runtime_env_context;
}

callback(true, serialized_runtime_env_context, "");
} else {
RAY_LOG(WARNING) << "Couldn't create a runtime environment for job " << job_id
Expand All @@ -1759,6 +1787,8 @@ void WorkerPool::GetOrCreateRuntimeEnv(const std::string &serialized_runtime_env
}

void WorkerPool::DeleteRuntimeEnvIfPossible(const std::string &serialized_runtime_env) {
return;

RAY_LOG(DEBUG) << "DeleteRuntimeEnvIfPossible " << serialized_runtime_env;
if (!IsRuntimeEnvEmpty(serialized_runtime_env)) {
runtime_env_agent_client_->DeleteRuntimeEnvIfPossible(
Expand Down
Loading