Lua Performance argument.


levi

Still fresh, damnit!
Joined
Oct 6, 2008
Messages
14,170
Location
Somewhere off the coast of the EU
I don't know if any of us here are familiar with the performance of Lua code to be honest. I assume it's the read in the anonymous function assigned to Updatewheel at least.
 

Djoga'Ro

moonstruck
Joined
Apr 3, 2016
Messages
1,957
For an interpreted language Lua is performant as hell. I haven't looked at code here. Is the Lua code's host being kept alive or does everything start from scratch on each call? (I don't actually know, how much Lua state initialisation costs. Just guessing it could amount to something perceivable.)
 

Djoga'Ro

moonstruck
Joined
Apr 3, 2016
Messages
1,957
On second thought, it should be quite a difference. Loading a Lua chunk cannot be done without handling lots of strings. For its execution many more strings than user data cannot be involved or Lua wouldn't be as fast as it is. Playing with strings is costly.
 

Letalis Sonus

Advanced Member
Joined
Mar 5, 2009
Messages
1,477
For its execution many more strings than user data cannot be involved or Lua wouldn't be as fast as it is. Playing with strings is costly.
It's called bytecode. Duh.

Using C for the standard implementation and the assembler-style interface with the scripting language are surely beneficial as well, the interpreter is tiny compared to others.
 

Letalis Sonus

Advanced Member
Joined
Mar 5, 2009
Messages
1,477
The language definition of Lua may sound like it's a scripting language, but its reference implementation is not - it wants you to believe that it is one. In reality it is closer related to Java, because it only executes bytecode, not scripts. The "interpreter" compiles everything into bytecode to be run onto an universal virtual machine instead of executing the Lua script directly. Most other scripting environments that allow bytecode (like Python) only offer it as an optional feature for more speed, but Lua only executes bytecode, just like Java.
 

elw3

ƐʍlƎ
Joined
Aug 10, 2010
Messages
1,594
Dont you dare compare it with such trash.

Also Lua is a language definition not its implementation.
For reference PUC Lua is about 20 times slower as C.
Luajit is almost identical in speed to C, it can however analyse the code and could for example clean up loops during runtime.
 

Djoga'Ro

moonstruck
Joined
Apr 3, 2016
Messages
1,957
@Letalis Sonus You're right. And if your point was that I might have brought my thoughts in better order and expressed myself more consise, you're correct, also. I'm hurting my head these days trying to get ros2 on fastdds to hand out message type information on request.
But I'm not wrong, am I. If the Lua binary gets started and the script loaded every iteration, that'd cost significantly more time than when keeping it up.
 

Letalis Sonus

Advanced Member
Joined
Mar 5, 2009
Messages
1,477
Dont you dare compare it with such trash.
The sadist in me is tempted to mention Rembulan. Oh wait, too late... Can you hear those sweet Lua screams from that juicy JVM over there~?

But I'm not wrong, am I. If the Lua binary gets started and the script loaded every iteration, that'd cost significantly more time than when keeping it up.
Makes me wonder if it actually implements caching for these sort of things. Testing it would be fairly easy: compile the script into pre-compiled bytecode and execute that instead and compare the results.
 
  • Haha
Reactions: rSl
Top