Skip to content

Commit

Permalink
fix duplicated ray worker logs (intel-analytics#2799)
Browse files Browse the repository at this point in the history
* fix multiple ray worker logs

* refine comments

* Update raycontext.py
  • Loading branch information
yangw1234 committed Sep 3, 2020
1 parent 71df432 commit 1cacac4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions python/orca/src/bigdl/orca/ray/raycontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ def register_pids(pids):
raise err


def kill_redundant_log_monitors(redis_address):

"""
Killing redundant log_monitor.py processes.
If multiple ray nodes are started on the same machine,
there will be multiple ray log_monitor.py processes
monitoring the same log dir. As a result, the logs
will be replicated multiple times and forwarded to driver.
See issue https://github.com/ray-project/ray/issues/10392
"""

import psutil
import subprocess
log_monitor_processes = []
for proc in psutil.process_iter(["name", "cmdline"]):
cmdline = subprocess.list2cmdline(proc.cmdline())
is_log_monitor = "log_monitor.py" in cmdline
is_same_redis = "--redis-address={}".format(redis_address)
if is_log_monitor and is_same_redis in cmdline:
log_monitor_processes.append(proc)

if len(log_monitor_processes) > 1:
for proc in log_monitor_processes[1:]:
proc.kill()


class RayServiceFuncGenerator(object):
"""
This should be a pickable class.
Expand Down Expand Up @@ -204,6 +230,7 @@ def _start_ray_services(iter):
object_store_memory=self.object_store_memory,
extra_params=self.extra_params),
tag="raylet")
kill_redundant_log_monitors(redis_address=redis_address)

yield process_info
return _start_ray_services
Expand Down Expand Up @@ -418,6 +445,9 @@ def init(self, driver_cores=0):
else:
self._start_cluster()
self._address_info = self._start_driver(num_cores=driver_cores)

print(self._address_info)
kill_redundant_log_monitors(self._address_info["redis_address"])
self.initialized = True
return self._address_info

Expand Down

0 comments on commit 1cacac4

Please sign in to comment.