Re: luajit 2.0b10 performance extremely brittle?

  • From: Michal Kottman <k0mpjut0r@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 4 Jun 2012 20:11:15 +0200

On 4 June 2012 17:27, Francesco Abbate <francesco.bbt@xxxxxxxxx> wrote:
> Hi,
>
> I've actually some experience writing optimized code for LuaJIT2.
> Usually you have to respect some rules to ensure that JIT code is
> actually generated and it does not fallback to interpreter mode.
>
> Normally what you should avoid is:
> - do not use global variables inside loops
>  * use local declarations to hold the variables
>  * use the 'strict' module to detect unintentional use of global variables
> - use an imperative style of coding:
>  * smart functional code tend to spoil optimization if closures have
>    to be createad inside a loop
> - avoid objects creation inside a loop
> - do not use deeply nested tables to hold the data used inside loops
> - write clean simple code
>
> If you respect these rules LuaJIT often make a very good job.

A list of such rules, maybe with some more explanation, and a small
guide on how to read/understand the output of -jv and -jdump in order
to optimize the code (i.e. what to look out for), would in my opinion
make a great topic for the LuaJIT wiki.

Other related posts: