mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
Add opt-in zRAM compression for the Steam client while a game runs (#442)
* Add opt-in zRAM compression for the Steam client while a game runs A "zRAM compression" toggle under Steam > Settings > Session, below "Keep downloads running". Off by default, kept once set, and disabled on devices without swap or with a kernel older than 5.4. When on, the session watches for Steam's reaper. 20 s into a game the client and its web helpers page their private anonymous memory out to the device's zram with MADV_PAGEOUT from inside their own process (libblsession zram.c, SIGURG), again every 5 minutes, and read every swapped page back once the game exits. No root is needed: only a process itself may do this without CAP_SYS_NICE. With the toggle off nothing is installed or started. RedMagic NP06J, Palworld: Steam's resident memory fell from ~1.7 GB to ~1.1 GB with ~560 MB in zram, available memory during play rose by ~0.5-0.8 GB, and ~2 MB was left in zram after the read-back. * Turn zRAM compression on by default below 12 GB of RAM Until the toggle is changed, it follows the device: on when the kernel supports it and the device has less than 12 GB of RAM, read from the advertised memory size on Android 14+ and from total memory before that. Turning it off is kept. --------- Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
1 parent
7987b04529
commit
9a6d48c04b
10 files changed
+513
No files matched your search
@@ -350,6 +350,8 @@ class MainActivity : ComponentActivity() {
|
||||
private var touchMode by mutableStateOf(SessionPrefs.TOUCH_AUTO)
|
||||
private var suspendPolicy by mutableStateOf(SessionPrefs.SUSPEND_MANUAL)
|
||||
private var steamDownloadsInBackground by mutableStateOf(false)
|
||||
private var zramCompression by mutableStateOf(false)
|
||||
private var zramSupported by mutableStateOf<Boolean?>(null)
|
||||
private var oscMode by mutableStateOf(SessionPrefs.OSC_AUTO)
|
||||
private var backActionsInverted by mutableStateOf(false)
|
||||
private var gameStorage by mutableStateOf("")
|
||||
@@ -1293,6 +1295,8 @@ class MainActivity : ComponentActivity() {
|
||||
touchMode = touchMode,
|
||||
suspendPolicy = suspendPolicy,
|
||||
steamDownloadsInBackground = steamDownloadsInBackground,
|
||||
zramCompression = if (mode == SessionService.MODE_STEAM) zramCompression else null,
|
||||
zramSupported = zramSupported,
|
||||
pipSupported = com.droiddeck.launcher.session.SessionPipController.supported(this),
|
||||
pipAutoEnter = pipAutoEnter,
|
||||
unfoldedControls = if (mode == SessionService.MODE_STEAM &&
|
||||
@@ -1351,6 +1355,7 @@ class MainActivity : ComponentActivity() {
|
||||
SessionPrefs.setSteamDownloadsInBackground(this, enabled)
|
||||
steamDownloadsInBackground = enabled
|
||||
},
|
||||
onZramCompression = { on -> SessionPrefs.setZramCompression(this, on); zramCompression = on },
|
||||
onPipAutoEnter = { on -> SessionPrefs.setPipAutoEnter(this, on); pipAutoEnter = on },
|
||||
onUnfoldedControls = { on -> SessionPrefs.setUnfoldedControls(this, on); unfoldedControls = on },
|
||||
onOsc = { o -> SessionPrefs.setOscMode(this, o); oscMode = o },
|
||||
@@ -1539,6 +1544,9 @@ class MainActivity : ComponentActivity() {
|
||||
// The sheet lifts at once, on what was last read; the slow part (driver files, a walk of the
|
||||
// added-games folders, the storage volumes) lands while it rises.
|
||||
Thread({
|
||||
val zram = com.droiddeck.launcher.core.ZramSupport.supported()
|
||||
val zramOn = SessionPrefs.zramCompression(this)
|
||||
ui.post { zramSupported = zram; zramCompression = zramOn }
|
||||
drivers.refreshDrivers()
|
||||
val storage = GameStorage.options(this)
|
||||
val deckyInstalled = if (mode == SessionService.MODE_STEAM) DeckyManager.installed(this) else null
|
||||
|
||||
Reference in new issue
Block a user