Page 1 of 1

20 % faster lua with goto labels

Posted: Tue Feb 04, 2020 12:06 pm
by trad_emark
According to this video recording of a talk from c++con, one can speed up LUA by small change in code - replacing large switch of functions with a table with goto label pointers, a generally unknown extension to c++.

https://youtu.be/IAdLwUXRUvg?t=1879 (do not let his hat distract you :D)

I do not know what LUA implementation is used in factorio and if rebuilding LUA from source is possible, but I thought it might be worth mentioning it here.

The factory must grow!

Re: 20 % faster lua with goto labels

Posted: Tue Feb 04, 2020 12:23 pm
by ratchetfreak
I would be surprised if the compiler didn't already do something like that. Large switch statements are a very attractive target for this kind of automatic optimization.

Re: 20 % faster lua with goto labels

Posted: Tue Feb 04, 2020 12:35 pm
by leadraven
No optimization is worth such blasphemy.