Wanted: lua profiler

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Wanted: lua profiler

Daurnimator
Thought I'd try something new and post to the mailing list looking for
existing solutions instead of writing one myself :)
I'd like to profile a mixed lua+C program/library.
What tools/solutions are out there? (a cursory search shows a few
solutions for lua 5.0 or 5.1, but these projects no longer work with
5.2/5.3)
How do people find out where the hot spots are in their lua programs?

The flamegraph tool comes with things for many languages (java,
node.js, etc: http://www.brendangregg.com/flamegraphs.html#Updates )
I know of agentzh's flamegraphs for luajit/openresty (
https://github.com/openresty/stapxx/blob/master/tapset/luajit.sxx )
Does someone have one of these for plain PUC lua?

Reply | Threaded
Open this post in threaded view
|

Re: Wanted: lua profiler

Simon Cozens
On 18/08/2015 08:17, Daurnimator wrote:
> What tools/solutions are out there? (a cursory search shows a few
> solutions for lua 5.0 or 5.1, but these projects no longer work with
> 5.2/5.3)

ProFi (https://gist.github.com/2838755) works for me on 5.2 at least.

S


Reply | Threaded
Open this post in threaded view
|

Re: Wanted: lua profiler

Yichun Zhang (agentzh)
In reply to this post by Daurnimator
Hello!

On Tue, Aug 18, 2015 at 3:17 PM, Daurnimator wrote:
> The flamegraph tool comes with things for many languages (java,
> node.js, etc: http://www.brendangregg.com/flamegraphs.html#Updates )
> I know of agentzh's flamegraphs for luajit/openresty (
> https://github.com/openresty/stapxx/blob/master/tapset/luajit.sxx )
> Does someone have one of these for plain PUC lua?
>

Well, I used to create a Lua-land flame graph tool for the standard
Lua 5.1 interpreter:

https://github.com/openresty/nginx-systemtap-toolkit#ngx-sample-lua-bt

It might need minor edits to get work outside the nginx context
though. Please let me know if you need help here.

I'm not interested in Lua 5.2/5.3 (for some practical reasons), sorry.

Regards,
-agentzh

Reply | Threaded
Open this post in threaded view
|

Re: Wanted: lua profiler

Luke Gorrie-2
In reply to this post by Daurnimator
On 18 August 2015 at 09:17, Daurnimator <[hidden email]> wrote:
Thought I'd try something new and post to the mailing list looking for
existing solutions instead of writing one myself :)

I have two areas of interest here.

First I am finding it really helpful to be able to profile at trace granularity. Traces seem to me like the natural unit of code optimization: try to have the right collection of them and make sure each is internally sensible. Here is the patch from Mike that I am using for this:


Second I am in the middle of hacking a low-level interface to the x86 PMU (Performance Monitoring Unit) by using dynasm to access the RDPMC instruction. This makes it possible to track fine-grained CPU performance events over arbitrary bits of Lua code.

I am racing to finish this before our second child is born.. any day now :).

Output looks like this:

selftest: pmu
328 counters found for CPU model GenuineIntel-6-3F
EVENT                                   TOTAL     /packet     /breath
instructions                      133,998,289       5.000     642.000
cycles                            665,169,797      24.000    3188.000
ref-cycles                        665,169,792      24.000    3188.000
uops_issued.any                   106,860,566       4.000     512.000
uops_retired.all                  106,843,031       4.000     512.000
br_inst_retired.conditional        26,702,752       1.000     128.000
br_misp_retired.all_branches              411       0.000       0.000
packet                             26,700,000       1.000     128.000
breath                                208,593       0.008       1.000
selftest ok

The work in progress code is here:

here is the draft API (not committed yet):

I would quite like to add this to LuaJIT directly. The obstacle is that I depend on Cosmin's extended dynasm that can be used from Lua code. I am considering bringing that into our LuaJIT branch perhaps as a submodule to replace the built-in dynasm.

This is me working my way up to our real application from the humble starting point:

Feedback welcome. Apologies if I fall off the internet for an extended period before finishing it :).

Cheers,
-Luke


Reply | Threaded
Open this post in threaded view
|

Re: Wanted: lua profiler

Luke Gorrie-2
On 18 August 2015 at 16:03, Luke Gorrie <[hidden email]> wrote:
First I am finding it really helpful to be able to profile at trace granularity. Traces seem to me like the natural unit of code optimization: try to have the right collection of them and make sure each is internally sensible. Here is the patch from Mike that I am using for this:

missing link: