gaogaotiantian/viztracer

inline viztracer cannot trace multiprocess

auderson opened this issue · 3 comments

test_mp.py:

import viztracer
import multiprocessing

def f():
    import time
    time.sleep(1)

# with viztracer.VizTracer(output_file="trace_mp.json"):
#     p = multiprocessing.Process(target=f)
#     p.start()
#     p.join()
p = multiprocessing.Process(target=f)
p.start()
p.join()

With viztracer test_mp.py, the log of the child process is reported. But the inline version (commented codes + python test_mp.py) cannot capture the child process.
image
image

This is not a bug. It's by design.

It's not trivial to make inline VizTracer work with multi processing. You'll have to use cmdline version for now if you want full multi process support.

It's not trivial to make inline VizTracer work with multi processing.

I guess so. I tried viztracer.patch.install_all_hooks() but it didn't work as expected.

No it won't work that easily. You need to collect the trace data generated by different processes. There could be ordering issues. VizTracer needs to patch before all the user code executes, and collect all the data after.