#Maybe Fast - Make Game Faster Mod

1 messages · Page 1 of 1 (latest)

cold lotus
#

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.

gaunt garnet
#

this doesnt do shit

cold lotus
#

short

gaunt garnet
#

shut up

cold lotus
gaunt garnet
#

do you think newer player will get what you're saying

#

😭

cold lotus
#

no

gaunt garnet
#

compared to the conversations you have in luajit2 thread

cold lotus
#

oh man but people still randomly ask me about luajit2

worthy sigil
cold lotus
#

it's going

#

im considering deleting lovely

worthy sigil
#

aw man

cold lotus
#

too much of a vibe killer

orchid cairn
#

"vibe killer" well maybe in this day and age on the programming field we need that

gaunt garnet
#

😭

worthy sigil
gaunt garnet
#

true

cold lotus
worthy sigil
cold lotus
#

I am a sinner

gaunt garnet
#

no

#

you're wrong

#

its actually Meta

#

AI

cold lotus
#

grok because grok has the anime waifu

gaunt garnet
#

they used this AI

orchid cairn
#

"ok, here's the rust code that will enable patching balatro"

if lovely.toml exists:
  patch(Balatro, lovely.toml)
cold lotus
#

jee thanks grokgpt now tell me a story about elon tusk

orchid cairn
#

jokes aside i appreciate the explanation of the optimization, always nice to see the details of the optimization that occurs

cold lotus
#

ah yeah I would've spent more time on it but i'm a bit braindead atm

#

just boils down to making jit happier, which typically involves making the code look worse 😭

gaunt garnet
# cold lotus

ported this into my modded copy from the forbidden device

#

it doesnt do shit

#

theres genuinely no saving for this

craggy pagoda
#

installing this 10 times to have the most optimized game possible

cold lotus
gaunt garnet
cold lotus
#

ya

cold lotus
cold frost
#

will buff tf2 men make my balatro run faster