blob: f00beb65036f2fee4a89944985948d8df214f900 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
Support partial JIT invalidation
LÖVE 11.5 game engine has switched over to using LuaJIT by default. This causes [Balatro](https://store.steampowered.com/app/2379780/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.
|