FEX-Emu / FEX-Emu/FEX

Support partial JIT invalidation

Open
#3,524 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
8k
Forks
351
Avg merge
12h 31m
Merged PRs (30d)
102

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.