Automatic Lua Profiling

###User story:
As a developer, it is painful and time-consuming to identify non-performant code in my games because existing profiling is utilized manually instead of automatically.

###Explanation of problem:

Back in September, we received a Lua performance profiling API. Unfortunately, this only profiles the performance of code we manually flag for review. There are a number of problems with this:

Location of non-performant code
Because the profiler only reviews sections of code I tell it to, I have to narrow down the non-performant code myself. This defeats one of the major benefits of profiling – communicating problematic code not only for me, but near-instantly at that. Manually narrowing down the issue is time-consuming, and when it comes to problem identification, cut/pasting half of the remaining code is just about as effective as the manual profiling API.

Provided information
Since I have to discover non-performant code on my own, the only thing remaining the profiler communicates to me is execution time. This helps test whether changes are faster or not, but if I’m properly optimizing something it should improve the code well enough that there’s a visible difference and a time difference isn’t as useful.

###A solution:
Python’s cProfile profiler is an example of optimal behavior. When enabled, it automatically tracks the execution time of user-implemented/system functions.

These results have been copied from the console into MS Excel for easier viewing – the results are sorted by percall. Viewing these results, I can clearly, instantly see that my two main bottlenecks are the compareUrls method and HTTP requests I’m making. If this were ROBLOX, I would have to paste profile blocks over and over until I identified the problem.

Manual profiling is great on a micro scale (e.g. finding out which part(s) of compareUrls cause performance issues), but it’s wholly unsuitable for macro scale profiling i.e. discovering the non-performant code in the first place. It’d be great if we were provided with automatic profiling for identifying issues, and then using manual profiling to increase the granularity of that information.

12 Likes