"profile.lua" a tool for finding bottlenecks

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Link
Prole
Posts: 19
Joined: Tue Jun 19, 2018 4:09 am

Re: "profile.lua" a tool for finding bottlenecks

Post by Link »

Thanks, very useful library, easier to use than others I found. I've added it to the list of Libraries in the Wiki: https://love2d.org/wiki/profile
User avatar
Przemator
Party member
Posts: 107
Joined: Fri Sep 28, 2012 6:59 pm

Re: "profile.lua" a tool for finding bottlenecks

Post by Przemator »

This profiling tool is fantastic. Thanks Ivan!

Would it be technically possible to make the profiling hierarchical? That is, if a function bar is called inside a function foo, it would be displayed as:

Code: Select all

Function   Calls   Time
/foo           1    5.0
/foo/bar       2    3.2
/foo/baz       1    1.5
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: "profile.lua" a tool for finding bottlenecks

Post by ivan »

Thanks Przemator.
It's certainly possible, but I'm not sure if it would be more useful.

Consider the following example:

Code: Select all

Function   Calls   Time
/foo           1    3.3
/foo/bar       2    3.2
/baz           1    1.6
/baz/bar       2    1.5
The "bar" function took 4.7 seconds of overall execution time but based on your suggestion
"bar" would be displayed as 2 different entries in the report ("foo/bar" and "baz/bar").

What if you have recursion with foo calling itself multiple times?

Code: Select all

foo
foo/foo
foo/foo/foo
Cheers!
User avatar
Przemator
Party member
Posts: 107
Joined: Fri Sep 28, 2012 6:59 pm

Re: "profile.lua" a tool for finding bottlenecks

Post by Przemator »

I work with Oracle, and the software I use generates really cool clickable SVG flame graphs.

Image

You're right, that it's useful to know the total elapsed time for a function, but it also helps to know which functions have been calling it. Don't know how the flame graph handles recurrence.
User avatar
Przemator
Party member
Posts: 107
Joined: Fri Sep 28, 2012 6:59 pm

Re: "profile.lua" a tool for finding bottlenecks

Post by Przemator »

By the way, regarding the memory issue. The way it’s solved on the Oracle database I work with is following. First the profiling data is dumped into a file, which just keeps growing. It can easily get to 2 GB in just a few minutes. Then I supply this file into a report generator, which either creates a HTML report or a SVG graph.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: "profile.lua" a tool for finding bottlenecks

Post by ivan »

Looks cool, somebody already managed to hookup Lua with KCacheGrind so it's definitely possible to produce more sophisticated visualizations/reports. Personally, I don't really need that sort of thing for now, but you are free to modify the code, and use it any way you like. Cheers!
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: "profile.lua" a tool for finding bottlenecks

Post by ivan »

Found a few problems with the profiler under LuaJIT (JIT doesn't trigger the "return" event when recursion is involved).
I have just released a patch to account for that, but it's not perfect. Note that C-functions are not supported at all.
https://github.com/2dengine/profile.lua
Use at your own risk!
Last edited by ivan on Sat Dec 11, 2021 8:22 am, edited 2 times in total.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: "profile.lua" a tool for finding bottlenecks

Post by ivan »

Just pushed a major update that verifies that the profiler works correctly with Love2D 11.3/LuaJIT 2.0.5 and Lua 5.3.
Please update your profile.lua if you are using this lib!
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests