Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support partial JIT invalidation #3524

Open
Sonicadvance1 opened this issue Mar 28, 2024 · 0 comments
Open

Support partial JIT invalidation #3524

Sonicadvance1 opened this issue Mar 28, 2024 · 0 comments

Comments

@Sonicadvance1
Copy link
Member

LÖVE 11.5 game engine has switched over to using LuaJIT by default. This causes Balatro to /constantly/ JIT code through code invalidations.

This is due to how LuaJIT compiles, it allocates 128KB at the start, and each time it generates new JIT code it changes permission of the code segment to RW for the full range, JITs code by appending to the end, and then changes back to RX. This causes FEX to invalidate all code in that mapping and spend all CPU time JITTing the same code over and over. This drops the game to sub 1FPS.

If we recognize that a region is a JIT region and do partial invalidations this will significantly improve the situation.
We could do this by:

  • hashing a JIT region code upfront (xxhash likely)
  • On invalidation just remove jump entries
  • On JIT, just do a lookup and hash check to put the entry back in JIT

This will have a bit of stampeding in the JIT after each invalidation, but better than full reJIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant