austin-python icon indicating copy to clipboard operation
austin-python copied to clipboard

Key Error: mode when running either austin2speedscope or austin2pprof on windows 10

Open skewballfox opened this issue 2 years ago • 8 comments

Description

upon running either austin2speedcope.exe input.austin output.speedscope or austin2pprof.exe input.austin output.pprof I run into the following error:

  File "<pythonpath>\LocalCache\local-packages\Python310\site-packages\austin\format\speedscope.py", line 212, in main
    mode = fin.metadata["mode"]
KeyError: 'mode'

Steps to Reproduce

  1. generate a austin profile via austin -P .\.venv\Scripts\python.exe launch.py 1>wall_time.austin
  2. run either command to convert the file to another format

Expected behavior: [What you expect to happen]

conversion happens and new file is created Actual behavior: [What actually happens] command errors out with a stacktrace ending in the above message

Reproduces how often: [What percentage of the time does it reproduce?] 100%

Versions

PS > austin --version
austin 3.5.0
PS > austin2pprof.exe --version
0.1.0
PS > austin-compress.exe --version
0.2.0
PS > austin2speedscope.exe --version
0.2.1
PS > python --version
Python 3.10.10

this is on windows 10

Additional Information

this seems related to the Metadata class inside stats.py. mode is one of the metadata fields listed at the top of the austin output file (in the output from the command in the steps to reproduce the line reads # mode: wall

skewballfox avatar Mar 17 '23 20:03 skewballfox

@skewballfox thanks for reporting this. Can I double-check with you that by

mode is one of the metadata fields listed at the top of the austin output file

you mean that the data you have collected from austin contains the # mode: wall line, please? I have tried to reproduce this on a mac but the austin2... commands seem to work as expected. I'll give it a go on a Windows machine as well soon to confirm.

P403n1x87 avatar Mar 19 '23 12:03 P403n1x87

I've tested with austin -P python -c "from time import sleep; sleep(2)" within a virtual environment and I was able to convert the data to the speedscope format. I look forward to your confirmation that indeed # mode: wall is contained in your sample file.

P403n1x87 avatar Mar 19 '23 22:03 P403n1x87

Here's the line responsible for it in Austin

On Sun, Mar 19, 2023, 5:08 PM Gabriele N. Tornetta @.***> wrote:

I've tested with austin -P python -c "from time import sleep; sleep(2)" within a virtual environment and I was able to convert the data to the speedscope format. I look forward to your confirmation that indeed # mode: wall is contained in your sample file.

— Reply to this email directly, view it on GitHub https://github.com/P403n1x87/austin-python/issues/16#issuecomment-1475413542, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG7UDR7RQBBDACDMJIKEQ5DW457WXANCNFSM6AAAAAAV67LHLM . You are receiving this because you were mentioned.Message ID: @.***>

skewballfox avatar Mar 21 '23 18:03 skewballfox

hey, sorry for the delay. This is the metadata from the file in question

# austin: 3.5.0
# interval: 100
# mode: wall
# python: 3.10.10

skewballfox avatar Mar 27 '23 18:03 skewballfox

@skewballfox thanks for confirming that indeed all the metadata is available from the sample file. If the file in question does not contain any sensitive data, would you perhaps be able to share it so that I can do some local testing on it?

P403n1x87 avatar Mar 31 '23 11:03 P403n1x87

I wish I could but while the project doesn't contain any sensitive information, it's export controlled. plus, it's pretty gargantuan about a Gigabyte in size.

skewballfox avatar May 23 '23 20:05 skewballfox

Not sure if this is related: austin2pprof does not seem to be generating legal pprof output on either Mac or Linux -- at least Perfetto.dev can't read the generated pprof file.

Trivial small example program, original Austin output, and austin2pprof generated pprof file attached. Screenshot of failure from perfetto.dev below.

Command line: sudo austin -i 500ms -o testme-austin.out python3 testme.py

testme.zip

Screenshot 2024-01-06 at 3 01 15 PM

Note: speedscope output via austin2speedscope works fine.

emeryberger avatar Jan 06 '24 20:01 emeryberger

@emeryberger thanks for reporting this. I have opened the attached pprof file with pprof and (besides the expected complaint about the missing binary) the data seems to load fine

image

Getting a raw view of the protobuf data shows the full structure

$ go tool pprof -raw testme-austin.pprof
Main binary filename not available.
PeriodType:
Period: 0
Samples:
Wall time/μs
    2519787: 1 2
                Process ID:[92879] Thread ID:[0:7908102144]
     500431: 3 2
                Process ID:[92879] Thread ID:[0:7908102144]
Locations
     1: 0x0 M=1 increment /Users/emerydb/Documents/testme.py:7 s=0()
     2: 0x0 M=1 <module> /Users/emerydb/Documents/testme.py:9 s=0()
     3: 0x0 M=1 increment /Users/emerydb/Documents/testme.py:6 s=0()
Mappings
1: 0x0/0x0/0x0

I suspect that the Perfetto UI is perhaps expecting a somewhat different structure, considering that it seems to be mainly a tool for traces (the error also hints at ftrace: ftrace_bundle_tokenizer_errors). This is all I have been able to find out about file formats https://perfetto.dev/docs/quickstart/traceconv. So my guess would be that a pprof is not necessarily compatible with the Perfetto UI.

P403n1x87 avatar Jan 08 '24 13:01 P403n1x87