mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 22:38:16 +08:00
Updated task_profiles function to avoid future repetitive parsing. (#691)
* Updated task_profiles function to avoid future repetitive parsing. * Fix indentation. * Fixed according to comments. * Included updated test for task_profiles function. * Simplify test. * Fix indentation. * Fix.
This commit is contained in:
committed by
Robert Nishihara
parent
2d636d9278
commit
e16df6da9a
@@ -345,21 +345,44 @@ class GlobalState(object):
|
||||
executions of that task. The second element is a list of profiling
|
||||
information for tasks where the events have no task ID.
|
||||
"""
|
||||
task_info = dict()
|
||||
event_names = self.redis_client.keys("event_log*")
|
||||
results = dict()
|
||||
events = []
|
||||
for i in range(len(event_names)):
|
||||
event_list = self.redis_client.lrange(event_names[i], 0, -1)
|
||||
for event in event_list:
|
||||
event_dict = json.loads(event.decode("ascii"))
|
||||
event_dict = json.loads(event)
|
||||
task_id = ""
|
||||
for element in event_dict:
|
||||
if "task_id" in element[3]:
|
||||
task_id = element[3]["task_id"]
|
||||
if task_id != "":
|
||||
if task_id not in results:
|
||||
results[task_id] = []
|
||||
results[task_id].append(event_dict)
|
||||
else:
|
||||
events.append(event_dict)
|
||||
return results, events
|
||||
for event in event_dict:
|
||||
if "task_id" in event[3]:
|
||||
task_id = event[3]["task_id"]
|
||||
task_info[task_id] = dict()
|
||||
for event in event_dict:
|
||||
if event[1] == "ray:get_task" and event[2] == 1:
|
||||
task_info[task_id]["get_task_start"] = event[0]
|
||||
if event[1] == "ray:get_task" and event[2] == 2:
|
||||
task_info[task_id]["get_task_end"] = event[0]
|
||||
if event[1] == "ray:import_remote_function" and event[2] == 1:
|
||||
task_info[task_id]["import_remote_start"] = event[0]
|
||||
if event[1] == "ray:import_remote_function" and event[2] == 2:
|
||||
task_info[task_id]["import_remote_end"] = event[0]
|
||||
if event[1] == "ray:acquire_lock" and event[2] == 1:
|
||||
task_info[task_id]["acquire_lock_start"] = event[0]
|
||||
if event[1] == "ray:acquire_lock" and event[2] == 2:
|
||||
task_info[task_id]["acquire_lock_end"] = event[0]
|
||||
if event[1] == "ray:task:get_arguments" and event[2] == 1:
|
||||
task_info[task_id]["get_arguments_start"] = event[0]
|
||||
if event[1] == "ray:task:get_arguments" and event[2] == 2:
|
||||
task_info[task_id]["get_arguments_end"] = event[0]
|
||||
if event[1] == "ray:task:execute" and event[2] == 1:
|
||||
task_info[task_id]["execute_start"] = event[0]
|
||||
if event[1] == "ray:task:execute" and event[2] == 2:
|
||||
task_info[task_id]["execute_end"] = event[0]
|
||||
if event[1] == "ray:task:store_outputs" and event[2] == 1:
|
||||
task_info[task_id]["store_outputs_start"] = event[0]
|
||||
if event[1] == "ray:task:store_outputs" and event[2] == 2:
|
||||
task_info[task_id]["store_outputs_end"] = event[0]
|
||||
if "worker_id" in event[3]:
|
||||
task_info[task_id]["worker_id"] = event[3]["worker_id"]
|
||||
if "function_name" in event[3]:
|
||||
task_info[task_id]["function_name"] = event[3]["function_name"]
|
||||
return task_info
|
||||
|
||||
Reference in New Issue
Block a user