Filter out "comments" in inferno-flamegraph input
mrob95 opened this issue · comments
Mike Roberts commented
The austin Python profiler includes some metadata as "comments" in its output, e.g.:
# austin: 3.3.0
# interval: 100
# mode: wall
# python: 3.9.10
P247;T247;<frozen importlib._bootstrap>:_install_external_importers:1187;<frozen importlib._bootstrap>:_find_and_load:1007;<frozen importlib._bootstrap>:_find_and_load_unlocked:986;<frozen importlib._bootstrap>:_load_unlocked:680;<frozen importlib._bootstrap>:exec_module:838;<frozen importlib._bootstrap_external>:<module>:35;<frozen importlib._bootstrap>:_find_and_load:1007;<frozen importlib._bootstrap>:_find_and_load_unlocked:986;<frozen importlib._bootstrap>:_load_unlocked:680;<frozen importlib._bootstrap>:exec_module:768;<frozen importlib._bootstrap>:_call_with_frames_removed:228 53
...
P247;T247;/home/mike/profiling/test.py:<module>:6;/usr/lib/python3.9/dis.py:dis:79;/usr/lib/python3.9/dis.py:_disassemble_recursive:373;/usr/lib/python3.9/dis.py:disassemble:369;/usr/lib/python3.9/dis.py:_disassemble_bytes:404 180
# duration: 695345
# sampling: 6,15,159
# saturation: 10/3898
# errors: 4/3898
Most of these are correctly ignored as invalid lines by inferno-flamegraph
, but some (like # duration: 695345
) look enough like a valid sample to end up in the output svg. I think the original perl version correctly identifies all of them as invalid, since it uses a strict regex to parse lines.
It's fairly trivial to work around this with a sed '/^#/d'
, but it would be nice for austin
and inferno-flamegraph
to work together smoothly.
Would you accept a PR to filter out all lines which begin with #
in inferno-flamegraph
?
Thanks
Jon Gjengset commented
Absolutely — that seems reasonable!