chore: fixed color indicator for sleeping states

This commit is contained in:
Maarten A. Breddels 2020-12-15 09:02:27 +01:00
parent 3bf1384162
commit cf9f63f378
2 changed files with 6 additions and 3 deletions

View File

@ -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): 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)

View File

@ -164,9 +164,11 @@ def main(argv=sys.argv):
dur = time - last_sleep_time[pid] dur = time - last_sleep_time[pid]
if takes_gil(last_sleep_stacktrace[pid]): if takes_gil(last_sleep_stacktrace[pid]):
name = 'S(GIL)' name = 'S(GIL)'
cname = 'terrible'
else: else:
name = 'S' 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) trace_events.append(event)
last_run_time[pid] = time last_run_time[pid] = time
del last_sleep_time[pid] del last_sleep_time[pid]