I’ve used callgrind with Python before, but you need to explicitly
call it through the interpreter for callgrind to catch on. I think
this works, but it’s just from memory. If it doesn’t, Google callgrind
and Python; I know the answer is out there.
Thanks for your suggestion, my Kcachegrind works well now.
But this method (explicitly call through python interpreter) doesn’t
work
for Oprofile, I still can’t find the session name “dial_tone” in the
profiled data. BTW, if Kcachegrind works well with python application,
why
do you guys recommend Oprofile?
Kcachegrind can only show the cost of C++ functions, can we get the cost
of
python functions or python modules? Because it is more interesting to
look
at the cost of each gr modules in the python code level.
We recommended Oprofile from a longer history of using it, and that’s
it. I’ve actually switched over to using valgrind for all of my
analysis and profiling work. In many ways, I still prefer Oprofile
because it works within the Linux kernel, but recent updates to Ubuntu
have made it much more difficult to install and use Oprofile, and I
can’t be bothered any more to worry about stuff like that. So valgrind
with callgrind works great and it’s now my tool of choice.
But we should probably update the wiki to include information about
using callgrind wit Kcachegrind.
Kcachegrind can only show the cost of C++ functions, can we get the cost of
python functions or python modules? Because it is more interesting to look
at the cost of each gr modules in the python code level.
Sincerely,
Yang, Qing
Information Engineering, CUHK
If you’re doing performance critical stuff in Python, stop it
I’ve never worried about profiling Python code since any performance
critical stuff I’ve wanted to do, I do it in C++. Python is just for
interfacing and interacting with the GNU Radio flowgraph and blocks,
and that shouldn’t need profiling.
Information Engineering, CUHK
If you’re doing performance critical stuff in Python, stop it
I’ve never worried about profiling Python code since any performance
critical stuff I’ve wanted to do, I do it in C++. Python is just for
interfacing and interacting with the GNU Radio flowgraph and blocks,
and that shouldn’t need profiling.
To recast things in telecom/networking terms, I like to think of the
Python layer as the control plane, and the C++ layer as the
data plane.
There are still people out there who think that Python was a horrible
choice for Gnu Radio, because they think we’re pushing significant
data through the Python layer. The hier2 blocks that are written in
Python add to this confusion, since at casual glance, it looks like
we’re pushing data through Python with these, and of course, we’re
not. The hier2 blocks just “encapsulate” a bunch of C++ blocks
to make a composite block, but again, Python just plays the role of
“control/constructor” plane in these scenarios.
I was on the RTLSDR chat group yesterday when I pointed out that all the
fundamental blocks in Gnu Radio are written in C++, and I got a
“well, yeah, except for all those fancy demodulator/modulator
blocks”. So the misunderstanding is persistent.
–
Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
Chris,
That’s a good tip. I’ve used it before and found it nice to time the
runtime of a flowgraph.
So Qing, if that’s what you were talking about before, yes, something
like this is probably what you want to use to time the execution of a
block from the Python world. I might have been confused what you meant
by wanting to profile Python stuff.
Thanks for your suggestion, I would like to try it out.
Hi Tom,
Actually we are building a broadband OFDM system targeting at 20MHz. Now
the transmit part can support 20MHz transmitting (set argument -W 20M),
but
the receive part will block and show overrun message once we set
–sample-rate larger than 1M. We use Xeon w3530 and N210.
I think the reason is: the code of receiver is inefficient thus unable
to
process the samples from USRP in time. Before optimizing the code, I
should
first find the bottleneck–which module chokes my system–from the whole
system’s perspective. That’s why I want to profile python code rather
than
C++ code.