Discussion:
[Numba] Profiling Numba
Mark Dewing
2015-10-12 17:44:51 UTC
Permalink
I've created a prototype for profiling Numba code (based on the vmprof
stack sampler). It does function-level profiling of the JIT'ed code and
the Python code. The output can be viewed in KCachegrind.

It currently only works for 64-bit linux.

Install directions using Anaconda:
1. Create a new environment: 'conda create -n profiling python numpy', and
switch to it: 'source activate profiling'
2. Install prototype versions of Numba and llvmlite: 'conda install -c
https://conda.anaconda.org/mdewing numba-profiling'
3. Install prototype version of vmprof: 'conda install -c
https://conda.anaconda.org/mdewing vmprof-numba'
4. Make sure libunwind is installed. (On Ubuntu 'apt-get install
libunwind8-dev'.)

Profile a python script with 'vmprofrun <python script> [arguments to
script]'. The output file ('vmprof-<pid>.out') can be viewed with
KCachegrind.

More info here:
http://markdewing.github.io/blog/posts/prototype-for-profiling-python/


Mark
--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+***@continuum.io.
To post to this group, send email to numba-***@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/7a58a9c8-7d6a-4756-af8e-02e0d73cbe03%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
Brian Merchant
2015-10-12 19:21:28 UTC
Permalink
Funny. I just came online to ask how people go about profiling their numba
code, and I see your post!

When you say: "Install prototype versions of Numba and llvmlite: 'conda
install -c https://conda.anaconda.org/mdewing numba-profiling", do you
mean, the latest development version of numba (i.e. NOT the latest stable
release)?

Kind regards (and thanks!),
Brian
Post by Mark Dewing
I've created a prototype for profiling Numba code (based on the vmprof
stack sampler). It does function-level profiling of the JIT'ed code and
the Python code. The output can be viewed in KCachegrind.
It currently only works for 64-bit linux.
1. Create a new environment: 'conda create -n profiling python numpy', and
switch to it: 'source activate profiling'
2. Install prototype versions of Numba and llvmlite: 'conda install -c
https://conda.anaconda.org/mdewing numba-profiling'
3. Install prototype version of vmprof: 'conda install -c
https://conda.anaconda.org/mdewing vmprof-numba'
4. Make sure libunwind is installed. (On Ubuntu 'apt-get install
libunwind8-dev'.)
Profile a python script with 'vmprofrun <python script> [arguments to
script]'. The output file ('vmprof-<pid>.out') can be viewed with
KCachegrind.
http://markdewing.github.io/blog/posts/prototype-for-profiling-python/
Mark
--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+***@continuum.io.
To post to this group, send email to numba-***@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/046206ee-9b87-4f86-a634-aeedc11bb773%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
Mark Dewing
2015-10-13 02:18:52 UTC
Permalink
Brian,
To clarify - I meant that the particular versions I built and uploaded to
anaconda.org should be installed (this is is not in any stable or dev
version of Numba.) The listed conda command installs them from my channel
(specified by the -c option). That is also why I highly recommend
creating a separate environment to try this code - so this version of Numba
does not interfere with your regular install.

Let me know if it works for you

Mark
Post by Brian Merchant
Funny. I just came online to ask how people go about profiling their numba
code, and I see your post!
When you say: "Install prototype versions of Numba and llvmlite: 'conda
install -c https://conda.anaconda.org/mdewing numba-profiling", do you
mean, the latest development version of numba (i.e. NOT the latest stable
release)?
Kind regards (and thanks!),
Brian
Post by Mark Dewing
I've created a prototype for profiling Numba code (based on the vmprof
stack sampler). It does function-level profiling of the JIT'ed code and
the Python code. The output can be viewed in KCachegrind.
It currently only works for 64-bit linux.
1. Create a new environment: 'conda create -n profiling python numpy',
and switch to it: 'source activate profiling'
2. Install prototype versions of Numba and llvmlite: 'conda install -c
https://conda.anaconda.org/mdewing numba-profiling'
3. Install prototype version of vmprof: 'conda install -c
https://conda.anaconda.org/mdewing vmprof-numba'
4. Make sure libunwind is installed. (On Ubuntu 'apt-get install
libunwind8-dev'.)
Profile a python script with 'vmprofrun <python script> [arguments to
script]'. The output file ('vmprof-<pid>.out') can be viewed with
KCachegrind.
http://markdewing.github.io/blog/posts/prototype-for-profiling-python/
Mark
--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+***@continuum.io.
To post to this group, send email to numba-***@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/43f2f9ec-6c5f-470d-b321-3ae6f0e2783a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
Mark Dewing
2015-10-13 02:49:09 UTC
Permalink
Hi Antoine,
Responses below.
Hi Mark,
On Mon, 12 Oct 2015 10:44:51 -0700 (PDT)
Post by Mark Dewing
I've created a prototype for profiling Numba code (based on the vmprof
stack sampler). It does function-level profiling of the JIT'ed code and
the Python code. The output can be viewed in KCachegrind.
This sounds really cool. Do you think you can publish your code or
recipe somewhere?
Or is there something that could be integrated in Numba?
Changes to llvmlite are in the perf branch here:
https://github.com/markdewing/llvmlite/tree/perf
The two main changes are to output the JIT map file, and to keep the frame
pointer in the JIT'ed code.

The changes to Numba are really minimal, so I didn't create a github fork -
JIT event output is enabled (one line change), and it's compiled with
CFLAGS=-fno-omit-frame-pointer.

The changes to vmprof are
here: https://github.com/markdewing/vmprof-python/tree/numba

One potential issue with full integration is platform support - the vmprof
stack sampler hooks the Python binary in order get Python-level source
information, and that may be specific to each OS, bitness, and architecture.
Post by Mark Dewing
http://markdewing.github.io/blog/posts/prototype-for-profiling-python/
This talks about a file "/tmp/perf-<pid>.map", does it mean your code
is actually compatible with Linux perf, or is the name just a
coincidence?
Yes, it should be compatible with Linux perf, but I haven't tested it.
At some point we'd like to integrate some helpers in Numba to
facilitate profiling, but have up to now managed to avoid this task by
addressing other issues instead :-)
(for line-profiling, we would probably need to switch to LLVM 3.7
first: https://github.com/numba/llvmlite/pull/100)
Regards
Antoine.
--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users+***@continuum.io.
To post to this group, send email to numba-***@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/7397e197-17a0-4e51-9828-a3e5c81c564b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
Continue reading on narkive:
Loading...