Make get_py_stack return more stack frames (#9512)

This commit is contained in:
Max Fitton
2020-08-21 11:02:12 -07:00
committed by GitHub
parent f03caa4532
commit 17f801dc69
2 changed files with 10 additions and 11 deletions
+9 -10
View File
@@ -651,33 +651,32 @@ cdef void get_py_stack(c_string* stack_out) nogil:
except ValueError: # overhead of exception handling is about 20us
stack_out[0] = "".encode("ascii")
return
msg = ""
while frame:
msg_frames = []
while frame and len(msg_frames) < 4:
filename = frame.f_code.co_filename
# Decode Ray internal frames to add annotations.
if filename.endswith("ray/worker.py"):
if frame.f_code.co_name == "put":
msg = "(put object) "
msg_frames = ["(put object) "]
elif filename.endswith("ray/workers/default_worker.py"):
pass
elif filename.endswith("ray/remote_function.py"):
# TODO(ekl) distinguish between task return objects and
# arguments. This can only be done in the core worker.
msg = "(task call) "
msg_frames = ["(task call) "]
elif filename.endswith("ray/actor.py"):
# TODO(ekl) distinguish between actor return objects and
# arguments. This can only be done in the core worker.
msg = "(actor call) "
msg_frames = ["(actor call) "]
elif filename.endswith("ray/serialization.py"):
if frame.f_code.co_name == "id_deserializer":
msg = "(deserialize task arg) "
msg_frames = ["(deserialize task arg) "]
else:
msg += "{}:{}:{}".format(
msg_frames.append("{}:{}:{}".format(
frame.f_code.co_filename, frame.f_code.co_name,
frame.f_lineno)
break
frame.f_lineno))
frame = frame.f_back
stack_out[0] = msg.encode("ascii")
stack_out[0] = " | ".join(msg_frames).encode("ascii")
cdef shared_ptr[CBuffer] string_to_buffer(c_string& c_str):
cdef shared_ptr[CBuffer] empty_metadata
+1 -1
View File
@@ -124,7 +124,7 @@ def test_actor_task_refs(ray_start_regular):
assert count(info, PINNED_IN_MEMORY) == 1, info
assert count(info, USED_BY_PENDING_TASK) == 2, info
assert count(info, DESER_ACTOR_TASK_ARG) == 1, info
assert count(info, "test_memstat.py:test_actor_task_refs") == 2, info
assert count(info, "test_memstat.py:test_actor_task_refs") == 3, info
assert count(info, "test_memstat.py:make_actor") == 1, info
del x_id