From cf9f63f378895081a4e26640eb6fb4233473365d Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Tue, 15 Dec 2020 09:02:27 +0100 Subject: [PATCH] chore: fixed color indicator for sleeping states --- README.md | 5 +++-- per4m/perf2trace.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ad5aa58..0a17256 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,8 @@ Merge the viztracer and perf/per4m results into a single html file. Identify the problem (GIL visible, possible low instruction counts/cycle): -![image](https://user-images.githubusercontent.com/1765949/102130936-c4cd6400-3e51-11eb-9ded-7b9bd77a09db.png) +![image](https://user-images.githubusercontent.com/1765949/102187104-db0c0c00-3eb3-11eb-93ef-e6d938d9e349.png) -The purple 'S' blocks indicate the threads/processes are in a waiting state, this is clearly the GIL at work, which is switching after [`sys.getswitchinterval`](https://docs.python.org/3/library/sys.html#sys.getswitchinterval) (0.005 seconds) + +The dark red `S(GIL)` blocks indicate the threads/processes are in a waiting state due to the GIL, dark orange `S` is a due to other reasons (like `time.sleep(...)`). The regular pattern is due to Python switching threads after [`sys.getswitchinterval`](https://docs.python.org/3/library/sys.html#sys.getswitchinterval) (0.005 seconds) diff --git a/per4m/perf2trace.py b/per4m/perf2trace.py index c4519ca..8b2e631 100644 --- a/per4m/perf2trace.py +++ b/per4m/perf2trace.py @@ -164,9 +164,11 @@ def main(argv=sys.argv): dur = time - last_sleep_time[pid] if takes_gil(last_sleep_stacktrace[pid]): name = 'S(GIL)' + cname = 'terrible' else: name = 'S' - event = {"pid": parent_pid.get(pid, pid), "tid": pid, "ts": last_sleep_time[pid], "dur": dur, "name": name, "ph": "X", "cat": "process state"} + cname = 'bad' + event = {"pid": parent_pid.get(pid, pid), "tid": pid, "ts": last_sleep_time[pid], "dur": dur, "name": name, "ph": "X", "cat": "process state", 'cname': cname} trace_events.append(event) last_run_time[pid] = time del last_sleep_time[pid]