fix(session): stop re-compressing game memory every 30 s when the game reads it straight back (#2312)

* fix(session): stop re-compressing game memory every 30 s when the game reads it straight back

On devices with 13 GB or less, the low-memory page-out skipped its
read-back backoff whenever memory was nearly exhausted. When the game
was actively using what was compressed, it read it straight back, so
the session pushed and re-read gigabytes every 30 seconds, pinning all
cores and freezing the game for 5-10 s each time. The read-back check
now applies on that path too: an effective page-out still repeats every
30 s, an ineffective one backs off as on the normal path.

* zRAM: keep the read-back backoff on the nearly-out-of-memory path

* zRAM: retry a skipped page-out after 30 s when nearly out of memory
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-09 02:08:40 -05:00
1 parent 88d6b70881
commit 96a12465e0
2 files changed
+31 -6

No files matched your search

@@ -902,21 +902,21 @@ case $mode in
bl_session_pressure() {
bl_memory_read
[ "$_bl_game" = 1 ] && bl_low_ram && bl_memory_critical || return 0
local _wait=$_bl_tier_backoff _urgent=0 _before _pids _targets
[ "$_bl_available" -ge $((_bl_headroom / 2)) ] || _urgent=1 _wait=30
local _wait=$_bl_tier_backoff _before _pids _targets
[ "$_bl_available" -ge $((_bl_headroom / 2)) ] || [ "$_bl_tier_pushed" -lt 0 ] || _wait=30
[ "$_bl_tier_at" -lt 0 ] || [ $((SECONDS - _bl_tier_at)) -ge "$_wait" ] || return 0
if [ "$_bl_tier_at" -ge 0 ] && [ "$_bl_tier_pushed" -gt 0 ]; then
bl_tier_readback
if [ "$_bl_tier_back" -le $((_bl_tier_pushed / 2)) ]; then
_bl_tier_backoff=30
elif [ "$_urgent" = 0 ]; then
else
_bl_tier_backoff=$((_bl_tier_backoff * 2 > 300 ? 300 : _bl_tier_backoff * 2))
_bl_tier_at=$SECONDS _bl_tier_pushed=0
_bl_tier_at=$SECONDS _bl_tier_pushed=-1
step "zRAM: the game read back most of its last page-out, next try in ${_bl_tier_backoff} s"
return 0
fi
fi
_bl_tier_at=$SECONDS
_bl_tier_at=$SECONDS _bl_tier_pushed=0
bl_zram_pick game
bl_zram_usage "${_pids[@]}" > /dev/null
[ "$_bl_rss" -ge $((256 * 1024)) ] || return 0