plasma-umass / scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Apache License 2.0
11.68k stars 391 forks source link

Create a `HOWTO` doc #170

Open emeryberger opened 3 years ago

emeryberger commented 3 years ago

There's some accumulated wisdom about how to use Scalene in different contexts / for different ends, especially pointed out in issues. It'd be good to have these all in one place.

tcapelle commented 3 years ago

I would also would know how to use scalene... Is there a jupyter notebook with examples?

emeryberger commented 3 years ago

I just added one - feedback welcome! https://github.com/plasma-umass/scalene/blob/master/scalene-demo.ipynb

tcapelle commented 3 years ago

Thanks, please put his line on the readme:

# Load Scalene
%load_ext scalene
krbvroc1 commented 3 years ago

I just stumbled across this project and installed it on RaspPi (ARM) CPU. I ran a python program under it and it does show an initial page of output, but nothing beyond that. It doesn't seem to output periodically or update the display or anything useful. A HOWTO might be useful for explain real-world usage. Or maybe even mention whether RaspPi is a supported platform. It does print 'Scalene warning: currently only 64-bit x86-64 and ARM platforms are supported for memory and copy profiling'.

emeryberger commented 3 years ago

Scalene emits one profile at the end of execution unless you tell it to output periodically (best to a file). For example, for a long-running program, you can do this:

scalene --profile-interval 10 --outfile prof.txt

will write a profile to the file prof.txt every 10 seconds.

You can also control when profiling takes place if you launch Scalene in the background. This info is available if you run:

scalene --help

We do not specifically support Raspberry Pi but we'd certainly welcome a PR with any required changes that might be needed for that platform!

krbvroc1 commented 3 years ago

Yes, I did try those various options...specifically --profile-interval 10 to an output file and it only output once at the beginning, which not very helpful stats (telling me time was spent on an import for example). So perhaps that is an indication that it just doesn't work on RaspPi (or its ARM processor).

emeryberger commented 3 years ago

So it sounds like you might just have a quite short-lived program (Scalene works fine on ARM, at least the Apple M1 version), but on the other hand, it could point to an issue. If you can share the code - assuming it's generic enough - we can see what happens on other platforms. If it's Pi specific, let me know if it might work on the 400 (since that seems like a reasonable platform for testing on our end).

krbvroc1 commented 3 years ago

It is a python program with 3 threads which never exits on its own (requires Ctrl-C)... it is quite complex to. I will get back to you on whether i can share.

Tree12323 commented 3 years ago

I'm a first time user, and would like to use scalene to profile only specific functions with '@Profile'. There's no some documentation about it. I need a usage example about it.