From e4de6ad3e9d108d766a22cddd7ad11f227d3196c Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Wed, 6 Jan 2021 20:06:58 +0100 Subject: [PATCH] chore: reorganize async GIL presentation --- per4m/perf2trace.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/per4m/perf2trace.py b/per4m/perf2trace.py index ff06636..0d4aec6 100644 --- a/per4m/perf2trace.py +++ b/per4m/perf2trace.py @@ -257,18 +257,22 @@ def gil2trace(input, verbose=1, take_probe="python:take_gil$", take_probe_return begin, end = 'B', 'E' event_id = int(time*1e3) name = "GIL-flow" - common = {"pid": parent_pid if as_async else f'{parent_pid}-GIL', "tid": f'{pid}', 'cat': 'GIL state', 'args': args, 'id': event_id, 'cname': 'terrible'} + common = {"pid": parent_pid if as_async else f'{parent_pid}-GIL', "tid": f'{pid}', 'cat': 'GIL state', 'args': args, 'id': event_id, 'cname': 'bad'} # we may have called take_gil earlier than we got it back # sth like [called take [ take success [still dropping]]] + yield header, {"name": 'GIL', "ph": begin, "ts": wants_take_gil[pid], **common, 'cname': 'bad'} if not only_lock and pid in wants_take_gil: - yield header, {"name": 'GIL(take)', "ph": begin, "ts": wants_take_gil[pid], **common, 'cname': 'bad'} - yield header, {"name": 'GIL', "ph": begin, "ts": time_gil_take + jitter, **common} + yield header, {"name": 'take_gil', "ph": begin, "ts": wants_take_gil[pid], **common} + yield header, {"name": 'take_gil', "ph": end, "ts": time_gil_take, **common} + assert time_gil_take >= wants_take_gil[pid], f"{time_gil_take} >= {wants_take_gil[pid]}" + yield header, {"name": 'LOCK', "ph": begin, "ts": time_gil_take, **common, 'cname': 'terrible'} + yield header, {"name": 'LOCK', "ph": end, "ts": wants_drop_gil[pid], **common, 'cname': 'terrible'} if not only_lock: - yield header, {"name": 'GIL(drop)', "ph": begin, "ts": wants_drop_gil[pid], **common} - yield header, {"name": 'GIL(drop)', "ph": end, "ts": time_gil_drop, **common} - yield header, {"name": 'GIL', "ph": end, "ts": time_gil_drop, **common} - if not only_lock and pid in wants_take_gil: - yield header, {"name": 'GIL(take)', "ph": end, "ts": time_gil_drop, **common, 'cname': 'bad'} + yield header, {"name": 'drop_gil', "ph": begin, "ts": wants_drop_gil[pid], **common} + yield header, {"name": 'drop_gil', "ph": end, "ts": time_gil_drop, **common} + # if not only_lock and pid in wants_take_gil: + yield header, {"name": 'GIL', "ph": end, "ts": time_gil_drop, **common, 'cname': 'bad'} + assert time_gil_drop >= wants_drop_gil[pid] else: if event not in ignored: print(f'ignoring {event}', file=sys.stderr)