ComputerCraft + LuaJIT = CCLuaJIT = WINNING

Started by sci4me, Jan 21, 2019, 05:09 am

Previous topic - Next topic

sci4me

What do you get when you take ComputerCraft and LuaJIT and mash them together? High-performance Lua programs running in your Minecraft world! On my machine, using a (probably poorly written) SHA-256 benchmark program, I observed a ~10-13x speedup.

This is best expressed visually:

This mod currently works on Minecraft 1.7.10 with ComputerCraft 1.7-1.75. In the future, I intend to support other versions.
I hope to release the mod in the coming weeks, if possible. Worst case scenario, in the next month.

Justyn

Is there a specific reason you picked CC 1.7.10?

sci4me

Quote from: Justyn on Jan 21, 2019, 06:19 amIs there a specific reason you picked CC 1.7.10?

It's the version I prefer to play, personally. However I definitely intend to support other versions. It's just a matter of time until I look into doing so. This will happen _after_ the initial release for 1.7.10.


SquidDev

Quote from: sci4me on Jan 31, 2019, 02:54 amInitial version is available! http://www.computercraft.info/forums2/index.php?/topic/29784-mc-1710-ccluajit/
Thanks for posting this! I've had a quick look through the code online (haven't loaded it up in an IDE yet), and just curious about the handling of "special" events and the custom task scheduler? I'm assuming it's designed to work around the fact that ILuaContext.yield blocks, yet Lua's yield doesn't, I just haven't been able to work out the intricacies.


On a side note, it might just be nicer to depend on CC's jar, rather than packaging stubs within api. Otherwise, looking really good!
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

sci4me

Quote from: SquidDev on Jan 31, 2019, 01:29 pm
Quote from: sci4me on Jan 31, 2019, 02:54 amInitial version is available! http://www.computercraft.info/forums2/index.php?/topic/29784-mc-1710-ccluajit/
Thanks for posting this! I've had a quick look through the code online (haven't loaded it up in an IDE yet), and just curious about the handling of "special" events and the custom task scheduler? I'm assuming it's designed to work around the fact that ILuaContext.yield blocks, yet Lua's yield doesn't, I just haven't been able to work out the intricacies.


On a side note, it might just be nicer to depend on CC's jar, rather than packaging stubs within api. Otherwise, looking really good!

Yeah, the "special event" thing is a workaround for when ILuaContext.yield blocks. In all honesty, I don't fully understand how it isn't a problem in normal CC but I suspect it's due to the fact that normal CC can actually call Lua's yield whereas I cannot.
I went down the path of a custom task scheduler in order to allow ILuaTasks to be run even when blocked in a "special event"...

Frankly, I think the entire codebase is utter trash and would like to just permanently delete the whole source code. *laughing while crying emoji*

And yeah, I might actually change it to depend on CC's jar.

Much improvement to-be-done! (Also fixing the one bug I found literally seconds after releasing the mod...)

SquidDev

Quote from: sci4me on Jan 31, 2019, 02:24 pmIn all honesty, I don't fully understand how it isn't a problem in normal CC but I suspect it's due to the fact that normal CC can actually call Lua's yield whereas I cannot.

Frankly, I think the entire codebase is utter trash and would like to just permanently delete the whole source code. *laughing while crying emoji*
CC uses LuaJ, which has a one-to-one correspondence between threads and coroutines. Thus yielding is little more than locking on this coroutine, and releasing one on the parent coroutine. It's a mess, and something I've been trying to resolve for a while, but very hard to do without breaking everything which depends on the CC API.

TBH, looking terrible is just the fate of anything which ends up messing around with CC internals, especially core mods. CCTweaks and Unborked were no better :D:.
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

sci4me

Quote from: SquidDev on Jan 31, 2019, 02:29 pm
Quote from: sci4me on Jan 31, 2019, 02:24 pmIn all honesty, I don't fully understand how it isn't a problem in normal CC but I suspect it's due to the fact that normal CC can actually call Lua's yield whereas I cannot.

Frankly, I think the entire codebase is utter trash and would like to just permanently delete the whole source code. *laughing while crying emoji*
CC uses LuaJ, which has a one-to-one correspondence between threads and coroutines. Thus yielding is little more than locking on this coroutine, and releasing one on the parent coroutine. It's a mess, and something I've been trying to resolve for a while, but very hard to do without breaking everything which depends on the CC API.

TBH, looking terrible is just the fate of anything which ends up messing around with CC internals, especially core mods. CCTweaks and Unborked were no better :D:.

Well, hopefully I'll be able to improve the codebase over time. But for now I'm more concerned about fixing bugs. :D

CrazedProgrammer

This is amazing! Never thought there would be a fork of CC that could be an order of magnitude faster :D
die($death);
db->close();

sci4me

Quote from: CrazedProgrammer on Jan 31, 2019, 08:23 pmThis is amazing! Never thought there would be a fork of CC that could be an order of magnitude faster :D

Not even a fork but just an addon!

Thanks for the feedback! Much work is to be done but, so far so good.