Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Optimize performance #21

Closed
raffomania opened this issue Feb 11, 2015 · 5 comments
Closed

Optimize performance #21

raffomania opened this issue Feb 11, 2015 · 5 comments

Comments

@raffomania
Copy link
Member

http://lua-users.org/wiki/ProfilingLuaCode could be of help.

@LuminescentMoon
Copy link
Contributor

Love2D uses LuaJIT. According to this page pairs() is not JIT compiled. So any instruction path that uses pairs() would not benefit from the performance improvements of the LuaJIT runtime.

Looking through the code, I believe there are some usage of pairs() that could be replaced ipairs(). Doing so would be a first step towards improving overall performance.

@Nukesor
Copy link
Member

Nukesor commented Dec 16, 2015

Thx for the advice and the website, it looks really helpful.
We are currently looking into some profiling tools as well, so there will hopefully be some progress on this issue soon.

@LuminescentMoon
Copy link
Contributor

LuaJIT v2.1 has a built-in sampling profiler. One of the output formats it supports looks pretty neat:

$ luajit -jp=a spectralnorm.lua 4000
====== spectralnorm.lua ======
 <at>  <at>  3  <at>  <at> 
      | -- contributed by Mike Pall
      | 
      | local function A(i, j)
  10% |   local ij = i+j-1
  25% |   return 1.0 / (ij * (ij-1) * 0.5 + i)
      | end
      | 
      | local function Av(x, y, N)
      |   for i=1,N do
      |     local a = 0
  32% |     for j=1,N do a = a + x[j] * A(i, j) end
      |     y[i] = a
      |   end
      | end
 <at>  <at>  18  <at>  <at> 
      | local function Atv(x, y, N)
      |   for i=1,N do
      |     local a = 0
  32% |     for j=1,N do a = a + x[j] * A(j, i) end
      |     y[i] = a
      |   end
      | end

@raffomania
Copy link
Member Author

Wow, we didn't know about that, thanks a lot. @Nukesor and me are still looking for some time to throw at this ticket, if in the meantime you find out more feel free to open a PR or comment again :)

@LuminescentMoon
Copy link
Contributor

It also has a feature where you could label sections of code as zones for an easier to read profiler output. E.g. a game could make use of an "AI" zone, a "PHYS" zone, etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants