Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Lua Interpreter

Lua Interpreter

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Cyote   (9 posts)  Bio
Date Wed 16 Jul 2014 12:34 PM (UTC)
Message
Is it possible to change the lua interpreter with luaj interpreter?
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #1 on Wed 16 Jul 2014 07:22 PM (UTC)
Message
Errrrr...maybe? But why? What do you gain from injecting a Java VM?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Cyote   (9 posts)  Bio
Date Reply #2 on Thu 17 Jul 2014 01:19 PM (UTC)
Message
Well it says its faster then lua in its website

Also my main reason is you can reach java abilities with it.
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #3 on Thu 17 Jul 2014 03:16 PM (UTC)

Amended on Thu 17 Jul 2014 03:31 PM (UTC) by Fiendish

Message
Cyote said:

Well it says its faster then lua in its website

Actually, the luaj website says the interpreter is slightly faster on _some_ benchmarks and is much slower on others. Even using their lua-to-java-bytecode compiler only gets you allegedly better performance on some subset of benchmarks and worse performance on others. That doesn't sound very compelling.

If you want better performance, use LuaJIT. It's a drop in replacement DLL that doesn't require a bunch of work punching through an injected Java VM with JNI.

Quote:
Also my main reason is you can reach java abilities with it.

For what? What Java abilities are we talking about here?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,159 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 17 Jul 2014 07:40 PM (UTC)

Amended on Fri 18 Jul 2014 06:15 AM (UTC) by Nick Gammon

Message
As I recently replied to another poster, the standard Lua is still quite fast. See this page:

http://www.gammon.com.au/forum/?id=10346

That shows scrolling chat, a map window that is redrawn rapidly, even a 3D view where each pixel is calculated individually, in Lua.

Fiendish uses LuaJIT in the Aardwolf release to get some extra performance out of Lua, and he is happy with that.

Unless you are into a lot of graphics-based stuff (like Aardwolf is with a lot of miniwindows) then you would hardly need much extra speed for a text-based MUD.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #5 on Thu 17 Jul 2014 08:01 PM (UTC)

Amended on Thu 17 Jul 2014 08:03 PM (UTC) by Fiendish

Message
Nick Gammon said:

Fiendish uses LuaJIT in the Aardwolf release to get some extra performance out of Lua.


Honestly, I'm not even sure I get much extra performance out of it. I guarantee that most of my time is spent waiting on disk and network I/O and screen drawing which are both outside of Lua's hands, and the JIT compiler likely never has a chance to warm up, so at best we have a small speedup from a more optimized interpreter. I challenge anyone to demonstrate a purely algorithmic plugin of the sort that would benefit from a faster interpreter.
I think the main benefit is unfettered Win32 access via FFI.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,159 posts)  Bio   Forum Administrator
Date Reply #6 on Thu 17 Jul 2014 09:18 PM (UTC)
Message
Which is used for what purpose?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,159 posts)  Bio   Forum Administrator
Date Reply #7 on Thu 17 Jul 2014 10:59 PM (UTC)
Message
Quote:

I think the main benefit is unfettered Win32 access ...


I'm sure Fiendish knows this, but for the benefit of others who may not, you can extend Lua to call any Win32 function by writing your own custom DLLs. A write-up on doing this is here:

http://www.gammon.com.au/forum/?id=4915

Not only can you call Windows functions, you can also call "back" into the Lua code if you need to (eg. to do a ColourNote).

Now of course you need to compile (and supply if you distributing copies) the DLL, but if you are going to distribute the LuaJIT DLL you may as well distribute one written to your own requirements.

Plus, you can compile using Cygwin which is a free compiler for Windows (amongst other things).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #8 on Thu 17 Jul 2014 11:05 PM (UTC)

Amended on Thu 17 Jul 2014 11:11 PM (UTC) by Fiendish

Message
Quote:
Which is used for what purpose

In the case I'm thinking of, I think it's just one call to CreateDirectoryA. But it's a really useful call! :)

Quote:
Now of course you need to compile (and supply if you distributing copies) the DLL, but if you are going to distribute the LuaJIT DLL you may as well distribute one written to your own requirements.

With FFI you really get much more than just Win32 (you can use native C arrays interleaved with your Lua code, for example, if you _really_ want to press the GOFAST button). And it doesn't require compiling a new DLL to wrap one function at a time. I don't use it much, but I like that the option is there.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,159 posts)  Bio   Forum Administrator
Date Reply #9 on Fri 18 Jul 2014 06:19 AM (UTC)
Message
Fiendish said:

In the case I'm thinking of, I think it's just one call to CreateDirectoryA. But it's a really useful call! :)


<raises eyebrows>

From: http://www.gammon.com.au/forum/?id=12496

Fiendish said:

10 months passed between 2.0.2 and 2.0.3. Many of the commits in between were bug fixes. Some of them were actually hit by myself or my users. The same is happening between 2.0.3 and 2.0.4. If you're going to support LuaJIT, you should release a new DLL at least every month or two to stay on top of all of Mike's bug fixes until he stops making changes to the 2.0 branch.
In contrast, stock Lua is at least stable.


That seems a lot of work to get one function call. A tiny DLL called from standard Lua would give you the same result without having to keep an eye on LuaJIT bug fixes.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,159 posts)  Bio   Forum Administrator
Date Reply #10 on Fri 18 Jul 2014 06:23 AM (UTC)
Message
Can't you use os.execute to create a directory?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #11 on Fri 18 Jul 2014 02:21 PM (UTC)

Amended on Fri 18 Jul 2014 02:54 PM (UTC) by Fiendish

Message
Nick Gammon said:

That seems a lot of work to get one function call. A tiny DLL called from standard Lua would give you the same result without having to keep an eye on LuaJIT bug fixes.
Keep in mind that my goals are different than the average user's. I'm creating a package for an entire community, users and developers both, not just for me. I think that LuaJIT gives significantly greater flexibility, even if nobody uses that flexibility yet.

Also it's fun

I also can't discount that there is /some/ performance gain. I do remember doing tests at some point a long time ago, running around on Aardwolf with the mapper going. I remember the results being statistically significant. But I don't remember the results being particularly impressive, and we know that Aardwolf pulses runs much faster than most (all?) other games, so any significance would be yet diminished for other MUDs.

Quote:
Can't you use os.execute to create a directory?

Sure, but try it and report your experience? I started with that and then switched to a direct Win32 call because I was seeing a cmd.exe window flashing across my screen. The experience of rapidly transient black boxes that I couldn't quite read gave me a horrible sense of dread that I didn't want to pass on to other players.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,159 posts)  Bio   Forum Administrator
Date Reply #12 on Fri 18 Jul 2014 11:27 PM (UTC)
Message
You can hide that annoying extra window by passing SW_HIDE (ie. zero) as the fifth argument to utils.shellexecute.

For example, this code creates "foo" at the root level of C: without any window flickering into view.


assert (utils.shellexecute ("cmd", "/C mkdir foo", "c:\\", "open", 0))  


Omit that last "0" parameter and you see the window.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #13 on Tue 05 Aug 2014 02:33 AM (UTC)

Amended on Tue 05 Aug 2014 05:33 AM (UTC) by Fiendish

Message
Heh. ShellExecute returns before the file operation completes (noticeable on file copy), so it could be dangerous.

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


36,242 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.