ptitSeb / box86

Box86 - Linux Userspace x86 Emulator with a twist, targeted at ARM Linux devices
https://box86.org
MIT License
3.35k stars 232 forks source link

Game crashes if using paging memory with zswap or zram #557

Closed thaihugo closed 2 years ago

thaihugo commented 2 years ago

Hi,

first, I would like to thank you for creating such a great program. It really revolutionize gaming on the raspberry pi.

I have a strange bug to report. I'm currently using a 2GB raspberry pi 4. Some really memory intensive games like Crusader kings 2 runs, but I need to use a page file for them to work. It isn't using much of the pagefile (200-250 M), so I thought I would compress the memory using zram with a small size (200M) to gain a bit with compression and not using paging.

Launching the game would then crash. I guess the crashing point is when it starts to use the zram file, but the point of crash is not always exactly the same. I have a lean system, using only 150 M idle. The game never goes further than loading the gamesave.

The result is the same with zswap (using part of the memory to compress before writing to sd card)

Basically, any memory intensive game would run without this zram/zswap, but crash if enabled.

To test, you can enable zswap in the /boot/cmdline.txt adding "zswap.enabled=1" at the end. Game prone to crash are the paradox games (crusader kings 2, europa universalis 4) and "mount and blades warbands" with some heavy mods for example. Anything going over physical memory. Using the same config without the zswap or zram works.

Do you think this is something that could be solved, or do the emulation and memory mapping force this issue?

ptitSeb commented 2 years ago

I think this is just the limit of zram. I personaly don't like zram, I don't think it's a good solution, because using RAM when you need it most doesn't sound practical. The game probably use the memory for compressed stuff (like compressed texture, sound), and ZRAM cannot compress anything and end up just adding no memory. Sorry.

thaihugo commented 2 years ago

Yes, I understand perfectly. I was just hoping, as zswap had the same behaviour, and the game would work perfectly (but slow) on using paged memory that it would be a simple bug in memory allocation.

Thank you for you diagnosis.