LUAJIT (Compiled LUA?)

LUAJIT (Compiled LUA?)

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

LUAJIT (Compiled LUA?)

Post by REVENGE »

I know there was talk about why we couldn't implement this when Spring had just gotten lua support. Would it be more feasible to do it now? It could bring tremendous improvements to the speed of lua execution, maybe even allow an lua based scripting system to replace COB.

http://luajit.org/
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: LUAJIT (Compiled LUA?)

Post by aegis »

how do we know lua isn't already faster than cob? :)
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: LUAJIT (Compiled LUA?)

Post by lurker »

The for loop was TWENTY TIMES faster in lua. No one may be allowed to forget this.

Did trepan release any stats on his work in the area?
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: LUAJIT (Compiled LUA?)

Post by REVENGE »

Was he ever working on this? Last time this discussion came up, he said it was premature and unsuitable for use in Spring. I'd be delighted if work for this is already underway! :twisted:
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: LUAJIT (Compiled LUA?)

Post by lurker »

It is premature, and work is not underway. Sorry if I got your hopes up.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: LUAJIT (Compiled LUA?)

Post by aegis »

you sure he didn't say something about lua unit scripting being in the xbox patch?
I remember him talking about it recently

if unit scripts are faster, the engine will run better on older machines...
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: LUAJIT (Compiled LUA?)

Post by Evil4Zerggin »

I can believe that Lua is faster than COB. Although COB may look like C, it actually runs on a virtual machine, and a rather naive one at that. I would imagine that Lua has a magical virtual machine that does things much faster, given that more people are working on it.

Out of curiosity, are there any long-term plans to replace COB with Lua?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: LUAJIT (Compiled LUA?)

Post by trepan »

The work is not underway, it's completed, and archived.
As for performance results, raw code execution is only
part of the problem. Call-in/call-out delays, thread
management, and animation control all factor in as well.

As an example, my testing showed that I could run
100000 (10^5) thread switches per 30 game frames
(so 100000 per second), and have my frame rate go
from 380 fps to 310 fps. This required a rework of the
entire c++ lua call-in setup, a lua library customization,
and a rework of the lua side call-in management.

EDIT: corrected the switch count, was testing with
100000 threads, each with a fsleep(random(10, 50), tag)
call.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: LUAJIT (Compiled LUA?)

Post by lurker »

Completed? I should read my #lua backlog...

Edit: eh, it's too flaky from all the disconnects I'd been having.
Last edited by lurker on 06 Aug 2008, 05:08, edited 1 time in total.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: LUAJIT (Compiled LUA?)

Post by trepan »

Completed, as in done to the point where all COB
functionality could be replaced. I was not finished
with the animation / model rework that I had planned.
Luckily, you've got other kindly devs who seem to be
planning a rework of the animation system.

P.S. As for LuaJIT, look at its limitations; they haven't
changed since the first time I looked at it oh so long
ago.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: LUAJIT (Compiled LUA?)

Post by lurker »

Or you could release what you have :D

>_>

<_<
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Re: LUAJIT (Compiled LUA?)

Post by jcnossen »

Slightly OT: COB probably could be made a faster by converting the COB instructions to a better ordered set of instruction codes. Right now the VM loop switch statement is implemented by the compiler with a lot of branching, while the compiler could optimize it to use a lookup table if it gets the chance.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: LUAJIT (Compiled LUA?)

Post by imbaczek »

COB would be very easy to jit, too, but is it really that of a bottleneck?
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: LUAJIT (Compiled LUA?)

Post by REVENGE »

Wow, from what it sounds like, there really is no need for JIT...

Would you expect lua script support to be feature complete by next release? I know that work on the animation support is actually proceeding pretty quickly.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: LUAJIT (Compiled LUA?)

Post by lurker »

jcnossen wrote:Slightly OT: COB probably could be made a faster by converting the COB instructions to a better ordered set of instruction codes. Right now the VM loop switch statement is implemented by the compiler with a lot of branching, while the compiler could optimize it to use a lookup table if it gets the chance.
As long as you don't mind breaking any code that references instructions as data, which is probably 0 scripts atm.
Post Reply

Return to “Feature Requests”