P403n1x87 / austin

Python frame stack sampler for CPython
https://pypi.org/project/austin-dist/
GNU General Public License v3.0
1.67k stars 51 forks source link

Processes not recognized as Python as Rasberry pi #227

Open bfialkoff opened 1 month ago

bfialkoff commented 1 month ago

Description

I have a very simple script that for some reason isn't recognized as a python process. It seems that Austin doesn't recognise anything python on the raspberry pi. Below is a minimal example

Steps to Reproduce

from time import sleep
import os

os.system("sudo austin -Cp {} > res.austin &"format(os.getpid()))

def f2():
    print('going to sleep')
    sleep(0.1)
    print('waking up')
def f1():
    f2()

if __name__ == '__main__':
    print('start')
    for _ in range(10):
        f1()
    print('end')

Expected behavior: Should have a res.austin profile

Actual behavior: When I run on MacOS everything works as expected however when porting to raspberry pi. Austin says:

👾 It looks like you are trying to profile a process that is not a Python
process. Make sure that you are targeting the right application. If the Python
process is actually a child of the target process then use the -C option to
discover it automatically.

Reproduces how often: always works on mac never works on the pi.

Versions

running python 3.7 and austin 3.6.0 of the OS you're running.

Additional Information

The issue that seems most related is here My production code runs on a raspberry pi and is connected to hardware and sensors that i cant fully simulate in my dev environment so i is critical for me to be able to profile directly on device.

The python version is the python the raspberry pi ships with, and i built austin from source.

Help and advice much appreciated.

P403n1x87 commented 1 month ago

@bfialkoff please note that Austin 3.6 supports CPython 3.8 and above. If you want to use Austin with CPython 3.7 you will have to use version 3.5 instead. Could you try with that version, please? Let me know if that still doesn't work for you.

bfialkoff commented 1 month ago

I will try, and keep you posted next week. Thanks!

bfialkoff commented 1 month ago

I upgraded and installed python 3.11.5 from source on the raspberry pi and i am still getting the same message.

👾 It looks like you are trying to profile a process that is not a Python
process. Make sure that you are targeting the right application. If the Python
process is actually a child of the target process then use the -C option to
discover it automatically.
P403n1x87 commented 1 month ago

@bfialkoff thanks for checking. Does the same happen if you run

from time import sleep
import os

def f2():
    print('going to sleep')
    sleep(0.1)
    print('waking up')
def f1():
    f2()

if __name__ == '__main__':
    print('start')
    for _ in range(10):
        f1()
    print('end')

with austin -o res.austin python script.py?

bfialkoff commented 1 month ago

Thank for the reply! Yes the same happens, still thinks its not a python process

bfialkoff commented 1 month ago

Checking in, do you have any advice for me? Anything I can do to get this working? Or else alternate tools that i might be able to use. the critical feature here is the profiling of subsequent spawned process etc, i found cProfile, py-spy, pyisntrument didn't give me the insight i need.

P403n1x87 commented 1 month ago

@bfialkoff I haven't had the chance to look into this. You could try with echion, although I have not tested it on the RPi. It should provide similar functionality to Austin 🤞