I am working on the two completely unrelated features mentionned in the subject.
First one will allow to tell Gideros to render new frames only when contents have changed (if it can figure out), thus saving battery life in apps with mostly static content. I have it working on QT and HTML so far, and it seems to work really well: for my pro apps CPU usage has been reduced by 20% and GPU usage by 99%!
Second feature I am working on, is trying to make luau thread safe, so that Core.asyncCall routines could be turned to real threads if asked. Of course most Gideros API is not thread safe, but a few calls could be made thread safe easily, and pure lua routines could be executed in another core without issues. But making luau thread safe isn't easy at all, so one step at a time
Comments
Likes: MoKaLux, SinisterSoft
Fragmenter - animated loop machine and IKONOMIKON - the memory game
From the sounds of the preview thread on the Roblox forum about threading it seems that their Actors are coroutines that are also distributed across cores in separate Luau states as required. It will be interesting to see what tactics you are taking!
Likes: SinisterSoft
I also managed to run multiple Lua threads truly in parallel, but it is unstable currently (only works in debug compilation, crashes instantly when compiled with optimizations). I choose to suspend GC completely while parallel threads are running, this avoids a lot of locks/mutexes. GC will run when only main thread remains or parallel threads are suspended or waiting. That seems a fair trade of.
Likes: SinisterSoft
Re the threading, that seems like the way forward too. User threads could be expected to be GC-aware and periodically call some form of GC yield function that pauses thread execution until the main thread signals it to continue after it has safely run the GC.
https://deluxepixel.com
Likes: SinisterSoft, PaulR, MoKaLux, vitalitymobile
Here are a few figures showing the gain (or loss) relative to current single thread gideros:
- Table fill: 1T=-2,85% 2T=38% 4T=47%
- Prime number finding: 1T=1,81% 2T=46% 4T=67%
- Pure math: 1T=-0,68% 2T=39% 4T=55%
It is strange the one of the tests gave better results in single thread, that makes me think that my test procedure has some jitter depending on my PC workload.
Likes: SinisterSoft, MoKaLux, vitalitymobile
https://deluxepixel.com
Likes: SinisterSoft
https://github.com/oneapi-src/oneTBB
Maybe it helps you with some ideas to continue the current work.
Keep up the great work! Thank you so much for making Gideros better each day!
Likes: MoKaLux, hgy29
I have added support for shared lua tables (tables usable concurrently by several threads), one have to call table.share(t) to make a table shared.
I also added a Core.signal() call which create an object that can be used for thread synchronization. It exposes a wait() and a notify() call.
BUT, most Gideros API isn't thread safe, and no opengl call can be made outside main thread. We will need to check which calls are safe and which aren't, and possibly make some of them safe.
Likes: SinisterSoft
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh