mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
feat: adjustable RAM and VRAM caps for the container (#1537)
* feat: adjustable RAM and VRAM caps for the container Performance > Memory gets two sliders: - RAM cap (soft, Steam sessions): when the session is resident above the cap, the session watcher compresses the Steam client into zRAM, waits for its page-out acknowledgment, then compresses the rest of the session (processes that loaded libblsession) if still over. Nothing is closed. Measured at most every 30 s; the client is read back once usage drops below the cap. Invalid values leave the cap off. Needs zRAM swap. - VRAM cap: sets dxgi.maxDeviceMemory ahead of the game's own DXVK_CONFIG, so Direct3D games budget for less video memory. A game profile still wins. Applies from the next session. * fix: back off the RAM cap when paging out cannot get under it A cap below the game's working set was never met, so the watcher paged out the client and the whole session every 30 s for the rest of the session. Usage is still measured every 30 s, but after a page-out that leaves the session over the cap the next one waits twice as long (60 s up to 10 min), resetting once usage is under the cap. The client step is skipped while the client is already under 512 MB resident. * fix: RAM cap covers desktop Steam, signals each group once, no idle churn - Steam opened from the desktop runs the same session watcher, so the cap is exported whenever the Steam client runs, not only in Steam mode. - The second page-out goes to the rest of the session only; Steam was signalled again even when its own step had been skipped as already small. - A cap page-out while no game runs stays paged out. Reading the client back right away pushed it over the cap again and repeated every minute; only a game closing while over the cap still defers a read-back. * fix: RAM cap marks the client packed only when it compressed it When the cap skipped the client as already small during a game, it still recorded the client as packed, so the regular in-game client page-out waited up to 300 s for a page-out that never happened. --------- Co-authored-by: jazzyjames <182448902+jazzyjamesgames@users.noreply.github.com>
This commit is contained in:
1 parent
dfe8227f49
commit
2be08bc67d
10 files changed
+180
-13
No files matched your search
@@ -152,6 +152,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
private var syncFallback by mutableStateOf(true)
|
||||
private var fsyncFirst by mutableStateOf(false)
|
||||
private var gamescopeRealtime by mutableStateOf(false)
|
||||
private var ramCapMb by mutableStateOf(0)
|
||||
private var vramCapMb by mutableStateOf(0)
|
||||
private var gpuClockPin by mutableStateOf(false)
|
||||
private var prootNoSeccomp by mutableStateOf(false)
|
||||
private var prootFastPath by mutableStateOf(true)
|
||||
@@ -1799,6 +1801,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
fsyncFirst = fsyncFirst,
|
||||
gamescopeRealtime = gamescopeRealtime,
|
||||
gpuClockPin = gpuClockPin,
|
||||
ramCapMb = ramCapMb, vramCapMb = vramCapMb,
|
||||
deviceRamMb = (android.app.ActivityManager.MemoryInfo()
|
||||
.also((getSystemService(ACTIVITY_SERVICE) as android.app.ActivityManager)::getMemoryInfo).totalMem / (1024 * 1024)).toInt(),
|
||||
ramCapAvailable = com.droiddeck.launcher.core.ZramSupport.supported(),
|
||||
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, cursorComposite = cursorComposite,
|
||||
guestHostname = guestHostname, phantomWarning = phantomWarning,
|
||||
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
||||
@@ -1812,6 +1818,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on },
|
||||
onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on },
|
||||
onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on },
|
||||
onRamCapMb = { mb -> SessionPrefs.setRamCapMb(this, mb); ramCapMb = mb },
|
||||
onVramCapMb = { mb -> SessionPrefs.setVramCapMb(this, mb); vramCapMb = mb },
|
||||
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
||||
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
|
||||
onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on },
|
||||
@@ -2007,6 +2015,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
syncFallback = SessionPrefs.syncFallback(this)
|
||||
fsyncFirst = SessionPrefs.fsyncFirst(this)
|
||||
gamescopeRealtime = SessionPrefs.gamescopeRealtime(this)
|
||||
ramCapMb = SessionPrefs.ramCapMb(this)
|
||||
vramCapMb = SessionPrefs.vramCapMb(this)
|
||||
gpuClockPin = SessionPrefs.gpuClockPin(this)
|
||||
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
|
||||
prootFastPath = SessionPrefs.prootFastPath(this)
|
||||
|
||||
@@ -256,6 +256,8 @@ object DeviceReport {
|
||||
EsyncPacks.status(LinuxRuntime.rootDir(context)).let { k("droiddeck-esync packs", "${it.installed} installed, ${it.wanted} wanted") }
|
||||
k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up")
|
||||
k("gamescope realtime", SessionPrefs.gamescopeRealtime(context))
|
||||
k("RAM cap", SessionPrefs.ramCapMb(context).let { if (it > 0) "$it MB" else "off" })
|
||||
k("VRAM cap", SessionPrefs.vramCapMb(context).let { if (it > 0) "$it MB" else "driver default" })
|
||||
k("proot without seccomp", SessionPrefs.prootNoSeccomp(context))
|
||||
k("proot fast path", SessionPrefs.prootFastPath(context))
|
||||
k("Guest host name", SessionPrefs.guestHostname(context))
|
||||
|
||||
@@ -453,6 +453,18 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("gamescopeRealtime", on).apply()
|
||||
}
|
||||
|
||||
fun ramCapMb(context: Context): Int = prefs(context).getInt("ramCapMb", 0).coerceAtLeast(0)
|
||||
|
||||
fun setRamCapMb(context: Context, mb: Int) {
|
||||
prefs(context).edit().putInt("ramCapMb", mb.coerceAtLeast(0)).apply()
|
||||
}
|
||||
|
||||
fun vramCapMb(context: Context): Int = prefs(context).getInt("vramCapMb", 0).coerceAtLeast(0)
|
||||
|
||||
fun setVramCapMb(context: Context, mb: Int) {
|
||||
prefs(context).edit().putInt("vramCapMb", mb.coerceAtLeast(0)).apply()
|
||||
}
|
||||
|
||||
fun gpuClockPin(context: Context): Boolean = prefs(context).getBoolean("gpuClockPin", false)
|
||||
|
||||
fun setGpuClockPin(context: Context, on: Boolean) {
|
||||
|
||||
@@ -738,7 +738,11 @@ class SessionService : Service() {
|
||||
guest.add("BL_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0"))
|
||||
guest.add("BL_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
|
||||
if (SessionPrefs.cursorComposite(this)) guest.add("BL_CURSOR_COMPOSITE=1")
|
||||
if (com.droiddeck.launcher.core.ZramSupport.supported()) guest.add("BL_ZRAM=1")
|
||||
if (com.droiddeck.launcher.core.ZramSupport.supported()) {
|
||||
guest.add("BL_ZRAM=1")
|
||||
if (steamHere) SessionPrefs.ramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_RAM_CAP_MB=$it") }
|
||||
}
|
||||
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_VRAM_MB=$it") }
|
||||
guest.add("BANNER_AUDIO_DIRECT_DECAY=0")
|
||||
val extra = extraEnv() + com.droiddeck.launcher.agent.AgentEnv.beginSession(this)
|
||||
if (extra.none { it.startsWith("TU_DEBUG=") }) guest.add("$GAME_TU_DEBUG=" + (tuOverride ?: if (tuDriver) "sysmem" else ""))
|
||||
|
||||
@@ -18,7 +18,7 @@ object SettingsReset {
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "picturePosition",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "ramCapMb", "vramCapMb",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
"noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "cursorComposite",
|
||||
"guestHostname", "fexPreset", "forceSsbs", "logs", "storageDiagnostics",
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
class CoreRow(val core: Int, val label: String)
|
||||
|
||||
private const val MEMORY_CAP_STEP_MB = 256
|
||||
|
||||
@Composable
|
||||
fun PerformancePage(
|
||||
cores: List<CoreRow>,
|
||||
@@ -44,6 +46,10 @@ fun PerformancePage(
|
||||
fsyncFirst: Boolean,
|
||||
gamescopeRealtime: Boolean,
|
||||
gpuClockPin: Boolean,
|
||||
ramCapMb: Int,
|
||||
vramCapMb: Int,
|
||||
deviceRamMb: Int,
|
||||
ramCapAvailable: Boolean,
|
||||
prootNoSeccomp: Boolean,
|
||||
prootFastPath: Boolean,
|
||||
cursorComposite: Boolean,
|
||||
@@ -60,6 +66,8 @@ fun PerformancePage(
|
||||
onFsyncFirst: (Boolean) -> Unit,
|
||||
onGamescopeRealtime: (Boolean) -> Unit,
|
||||
onGpuClockPin: (Boolean) -> Unit,
|
||||
onRamCapMb: (Int) -> Unit,
|
||||
onVramCapMb: (Int) -> Unit,
|
||||
onProotNoSeccomp: (Boolean) -> Unit,
|
||||
onProotFastPath: (Boolean) -> Unit,
|
||||
onCursorComposite: (Boolean) -> Unit,
|
||||
@@ -123,6 +131,22 @@ fun PerformancePage(
|
||||
gpuClockPin, onChange = onGpuClockPin,
|
||||
)
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.perf_memory)) {
|
||||
val top = (deviceRamMb / MEMORY_CAP_STEP_MB * MEMORY_CAP_STEP_MB).coerceAtLeast(MEMORY_CAP_STEP_MB)
|
||||
val off = stringResource(R.string.perf_cap_off)
|
||||
val auto = stringResource(R.string.perf_cap_auto)
|
||||
SliderRow(
|
||||
stringResource(R.string.perf_ram_cap),
|
||||
if (ramCapAvailable) stringResource(R.string.perf_ram_cap_hint) else stringResource(R.string.perf_ram_cap_unavailable),
|
||||
ramCapMb.coerceAtMost(top), 0..top, step = MEMORY_CAP_STEP_MB, enabled = ramCapAvailable,
|
||||
format = { if (it == 0) off else "$it MB" }, onChange = onRamCapMb,
|
||||
)
|
||||
SliderRow(
|
||||
stringResource(R.string.perf_vram_cap), stringResource(R.string.perf_vram_cap_hint),
|
||||
vramCapMb.coerceAtMost(top), 0..top, step = MEMORY_CAP_STEP_MB,
|
||||
format = { if (it == 0) auto else "$it MB" }, onChange = onVramCapMb,
|
||||
)
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.perf_fixes)) {
|
||||
ToggleRow(
|
||||
host, "sysmem", stringResource(R.string.perf_sysmem),
|
||||
|
||||
@@ -552,6 +552,14 @@
|
||||
<string name="perf_gsrealtime">gamescope: realtime GPU queue</string>
|
||||
<string name="perf_gsrealtime_hint">Prioritizes the compositor\'s GPU work. Can smooth frame pacing at some cost to games.</string>
|
||||
<string name="perf_gpu">GPU</string>
|
||||
<string name="perf_memory">Memory</string>
|
||||
<string name="perf_cap_off">Off</string>
|
||||
<string name="perf_cap_auto">Driver default</string>
|
||||
<string name="perf_ram_cap">RAM cap</string>
|
||||
<string name="perf_ram_cap_hint">Applies while the Steam client runs, in Steam mode or from the desktop. When the session uses more than this, Steam and then the session\'s other supported processes are compressed into zRAM. A soft cap: nothing is closed, but games may stutter while pages come back.</string>
|
||||
<string name="perf_ram_cap_unavailable">Needs zRAM swap, which this device does not have.</string>
|
||||
<string name="perf_vram_cap">VRAM cap</string>
|
||||
<string name="perf_vram_cap_hint">The video memory DXVK reports to Direct3D games, so they budget textures for less. A game\'s own DXVK settings still win. Takes effect at the next session.</string>
|
||||
<string name="perf_gpuclock">Hold the GPU at its top clock</string>
|
||||
<string name="perf_gpuclock_hint">Adreno only. Fewer hitches, more battery use and heat.</string>
|
||||
<string name="perf_fixes">Session fixes</string>
|
||||
|
||||
Reference in new issue
Block a user