Consistent Name for Process Title (#6276)

* Consistent naming for setprotitle

* Address comments

* Add debug/verbose mode

* Fix test
This commit is contained in:
Simon Mo 2019-11-26 11:56:28 -08:00 committed by Eric Liang
parent 141d667cee
commit 1ca8c427e3
4 changed files with 22 additions and 11 deletions

View file

@ -536,14 +536,14 @@ cdef execute_task(
b' "task_id": ' + task_id.Hex() + b'}') b' "task_id": ' + task_id.Hex() + b'}')
if <int>task_type == <int>TASK_TYPE_NORMAL_TASK: if <int>task_type == <int>TASK_TYPE_NORMAL_TASK:
title = "ray_worker:{}()".format(function_name) title = "ray::{}()".format(function_name)
next_title = "ray_worker" next_title = "ray::IDLE"
function_executor = execution_info.function function_executor = execution_info.function
else: else:
actor = worker.actors[core_worker.get_actor_id()] actor = worker.actors[core_worker.get_actor_id()]
class_name = actor.__class__.__name__ class_name = actor.__class__.__name__
title = "ray_{}:{}()".format(class_name, function_name) title = "ray::{}.{}()".format(class_name, function_name)
next_title = "ray_{}".format(class_name) next_title = "ray::{}".format(class_name)
worker_name = "ray_{}_{}".format(class_name, os.getpid()) worker_name = "ray_{}_{}".format(class_name, os.getpid())
if c_resources.find(b"memory") != c_resources.end(): if c_resources.find(b"memory") != c_resources.end():
worker.memory_monitor.set_heap_limit( worker.memory_monitor.set_heap_limit(

View file

@ -420,7 +420,12 @@ def start(node_ip_address, redis_address, address, redis_port,
"--force", "--force",
is_flag=True, is_flag=True,
help="If set, ray will send SIGKILL instead of SIGTERM.") help="If set, ray will send SIGKILL instead of SIGTERM.")
def stop(force): @click.option(
"-v",
"--verbose",
is_flag=True,
help="If set, ray prints out more information about processes to kill.")
def stop(force, verbose):
# Note that raylet needs to exit before object store, otherwise # Note that raylet needs to exit before object store, otherwise
# it cannot exit gracefully. # it cannot exit gracefully.
processes_to_kill = [ processes_to_kill = [
@ -440,7 +445,7 @@ def stop(force):
["monitor.py", False], ["monitor.py", False],
["redis-server", True], ["redis-server", True],
["default_worker.py", False], # Python worker. ["default_worker.py", False], # Python worker.
["ray_", True], # Python worker. ["ray::", True], # Python worker.
["org.ray.runtime.runner.worker.DefaultWorker", False], # Java worker. ["org.ray.runtime.runner.worker.DefaultWorker", False], # Java worker.
["log_monitor.py", False], ["log_monitor.py", False],
["reporter.py", False], ["reporter.py", False],
@ -463,13 +468,19 @@ def stop(force):
str(len(keyword)) + ". Filter: " + keyword) str(len(keyword)) + ". Filter: " + keyword)
else: else:
ps_format = "pid,args" ps_format = "pid,args"
debug_operator = "| tee /dev/stderr" if verbose else ""
command = ( command = (
"kill -s {} $(ps ax -o {} | grep {} | grep -v grep | grep ray | " "kill -s {} $(ps ax -o {} | grep {} | grep -v grep {} | grep ray |"
"awk '{{ print $1 }}') 2> /dev/null".format( "awk '{{ print $1 }}') 2> /dev/null".format(
# ^^ This is how you escape braces in python format string. # ^^ This is how you escape braces in python format string.
signal_name, signal_name,
ps_format, ps_format,
keyword)) keyword,
debug_operator))
if verbose:
logger.info("Calling '{}'".format(command))
subprocess.call([command], shell=True) subprocess.call([command], shell=True)

View file

@ -1843,10 +1843,10 @@ def test_ray_setproctitle(ray_start_2_cpus):
@ray.remote @ray.remote
class UniqueName(object): class UniqueName(object):
def __init__(self): def __init__(self):
assert setproctitle.getproctitle() == "ray_UniqueName:__init__()" assert setproctitle.getproctitle() == "ray::UniqueName.__init__()"
def f(self): def f(self):
assert setproctitle.getproctitle() == "ray_UniqueName:f()" assert setproctitle.getproctitle() == "ray::UniqueName.f()"
@ray.remote @ray.remote
def unique_1(): def unique_1():

View file

@ -1094,7 +1094,7 @@ def connect(node,
# TODO(qwang): Rename this to `worker_id_str` or type to `WorkerID` # TODO(qwang): Rename this to `worker_id_str` or type to `WorkerID`
worker.worker_id = _random_string() worker.worker_id = _random_string()
if setproctitle: if setproctitle:
setproctitle.setproctitle("ray_worker") setproctitle.setproctitle("ray::IDLE")
elif mode is LOCAL_MODE: elif mode is LOCAL_MODE:
# Code path of local mode # Code path of local mode
if job_id is None: if job_id is None: