Message Passing based Multithreading

I’m a fan of multithreading in my day to day work (using C++) and I’m aware that threading in Lua isn’t done in the same way but it would be great to get some use out of those extra cores.

Any chance an API could be implemented to create multiple parallel Lua states that communicate via message passing? Maybe even something along the lines of Lualanes perhaps?

Lua Lanes looks really interesting. I wonder if we can use it directly, with all lanes being pure-Lua only (no Codea API)

Currently Codea runs across two “queues” (iOS abstraction over threads). The render queue, which runs Lua. And the main queue, which runs the UI and parameters

Drawing commands have to be dispatched to the render queue, and since Lua is running on that queue it is able to draw directly

@John is upgrading the Codea renderer to Metal, which is designed with multi-core in mind. It would be interesting to see if we can find a place for Lua Lanes or some other mechanism for multi-core concurrency

From my experience with Metal utilising multiple render queues can get gnarly very quickly.

I know the iOS games I’ve worked on have all had single threaded render pipelines and those were graphically complex ports so I can’t see adding threaded rendering to Codea being especially worthwhile at this point.

As this would essentially be creating additional lua_State’s just not importing the rendering portion of the Codea API would ensure any attempt to render on another thread just throws an error.

Any API that opens up more processing power and I’d be more than happy though.

Ah good to know that the effort is probably not worthwhile in terms of multi-threaded rendering