This is a pretty simple performance mod that, in best cases, give you a solid performance boost or will do absolutely nothing at all. I think that this is fitting considering the amount of time I spent working on it.
How does it work?
This code runs every frame:
for k, v in pairs(self.MOVEABLES) do
if v.FRAME.MOVE < G.FRAMES.MOVE then v:move(move_dt) end
end
for k, v in pairs(self.MOVEABLES) do
v:update(dt*self.SPEEDFACTOR)
end
self.MOVEABLES is an array of a bunch of different things that are all similar, but not similar enough. This makes JIT confused. It optimizes the first loop iteration, realizes that the "type" has changed on the next iteration, throws out the previous trace, re-compiles the current trace, etc. This faulty optimization loop continues until it gives up and marks this region of code as naughty.
I optimized this by grouping the items in self.MOVEABLES into new arrays, sorted by their "type". Each of these new arrays is iterated over separately in really ugly unrolled loops. This makes JIT happy as the happy path is now consistent and optimizable.
Possible performance uplift is anywhere from 0 to 20 FPS depending on your hardware. GPU bottlenecked systems wont get much from this. This wont fix lag that happens elsewhere (like Talisman scoring, for example), but in the perfect case this case make your game run a little bit quicker.
Also full transparency I'm only like 70% sure that this is the reason why it runs faster. It might not even be faster, who really knows.

