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

PPU LLVM: Fix memory leaks and protect against the rise of CPU threads in the coming years #15377

Merged
merged 4 commits into from
Mar 30, 2024

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Mar 30, 2024

  • In RPCS3 leaks memory on PPU compilation #15376, vsh.self is being precompiled. And when that happens, RPCS3 attempts to precompile nearly every PPU executable it finds lying inisde the firmware. By itself this is currently the intended behavior, but after some debugging I discovered that the memory of every executable lying inisde the "/dev_flash/sys/" is not being released after it finalizes.
    The proper way to do it is: whitelist only file under "/dev_flash/sys/external", of PRX type only and only if being done ingame.

  • The second problem is that RPCS3 naively allows concurrent loads of executable PPU files and their entire LLVM workloads per CPU thread. This is not only a cause for massive memory usages during precompilation but is also not really needed as each files may get multiple threads to compile it as well depending on its size. So I added a limit which allows to load files of total sum of RAM size / 800. This is not accurate but it does work nicely with the previousl limit for Overlay files of 2 with Metal Gear Solid 4 on 16GB of RAM.
    This should protect from most memory shortages in the near future when CPUs have even more threads.

  • Fix PPU LLVM memory cleanup of modules outside of /dev_flash/sys/external but inside /dev_flash even ingame, it turns out memory cleanup failed because the entry used to store the JIT instance uses a key that was different between creation access and removal access.

  • Minor SPU LLVM worker memory optimization when SPU LLVM ingame workers are not active.

Fixes #15376

@elad335 elad335 added Bugfix LLVM Related to LLVM instruction decoders labels Mar 30, 2024
@elad335 elad335 force-pushed the get-rid branch 2 times, most recently from 62f3fb3 to 1b632d4 Compare March 30, 2024 15:49
@elad335 elad335 force-pushed the get-rid branch 2 times, most recently from fccfcf1 to f316087 Compare March 30, 2024 16:06
@elad335 elad335 force-pushed the get-rid branch 2 times, most recently from 6f5bb83 to 8b8ea71 Compare March 30, 2024 17:57
They may not be active at all unless a ps3 application is booted.
@elad335 elad335 merged commit e90b399 into RPCS3:master Mar 30, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix LLVM Related to LLVM instruction decoders
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPCS3 leaks memory on PPU compilation
1 participant