mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
Default Snapdragon 8 Gen 2 core allocation (#654)
This commit is contained in:
1 parent
a7662ae13a
commit
5e5ffee93e
9 files changed
+209
-19
No files matched your search
@@ -177,6 +177,23 @@ export XDG_DATA_DIRS=$XDG_DATA_HOME/flatpak/exports/share:${XDG_DATA_DIRS:-/usr/
|
||||
# program from the rail): the user's game cores when set (BL_GAME_CPUS), else every core but the
|
||||
# slowest cluster - Android is free to park an emulator's threads on the little cores, and those
|
||||
# are what compile shaders and recompile PPU/SPU code. BL_PIN_CORES=0 leaves the scheduler alone.
|
||||
# A prime-only client mask can be reset without a thread-count change (Steam or Android).
|
||||
# Read status with shell builtins; only invoke taskset when a single-core mask has drifted.
|
||||
client_single_core_matches() {
|
||||
local wanted=$1 task key cpus
|
||||
shift
|
||||
[[ $wanted =~ ^[0-9]+$ ]] || return 0
|
||||
for task in "$@"; do
|
||||
[ -r "$task/status" ] || continue
|
||||
while read -r key cpus; do
|
||||
[ "$key" = Cpus_allowed_list: ] || continue
|
||||
[ "$cpus" = "$wanted" ] || return 1
|
||||
break
|
||||
done < "$task/status" 2>/dev/null
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
program_cores() {
|
||||
[ "${BL_PIN_CORES:-1}" = 0 ] && return 0
|
||||
command -v taskset >/dev/null 2>&1 || return 0
|
||||
@@ -445,8 +462,8 @@ case $mode in
|
||||
# reasonable thing to do while a game is running and the wrong thing when the client is all
|
||||
# there is. BL_CLIENT_CPUS overrides it. Re-applied on a beat because steamwebhelper spawns
|
||||
# children continuously and each one inherits Steam's choice, not ours. The beat reads /proc
|
||||
# itself instead of running pgrep, and only runs taskset for a process that is new or has
|
||||
# grown threads since it was last pinned: every fork is a round of traced syscalls, and a
|
||||
# itself instead of running pgrep, and runs taskset for new threads or a single-core mask
|
||||
# that has drifted since it was last pinned: every fork is a round of traced syscalls, and a
|
||||
# beat that forked a taskset per process every 5 s did that for an hour. taskset -a, because
|
||||
# without it only a process's main thread moves and the renderer's workers stay where they were.
|
||||
if [ -n "${BL_CLIENT_CPUS:-}" ]; then
|
||||
@@ -459,7 +476,9 @@ case $mode in
|
||||
case $_c in *steamwebhelper*|*steamrtarm64/steam|*gamescope*) ;; *) continue ;; esac
|
||||
_t=("$_d"/task/*)
|
||||
_p=${_d#/proc/}
|
||||
[ "${_bl_pinned[$_p]:-}" = "${#_t[@]}" ] && continue
|
||||
if [ "${_bl_pinned[$_p]:-}" = "${#_t[@]}" ] && client_single_core_matches "$BL_CLIENT_CPUS" "${_t[@]}"; then
|
||||
continue
|
||||
fi
|
||||
taskset -a -cp "$BL_CLIENT_CPUS" "$_p" >/dev/null 2>&1 || true
|
||||
_bl_pinned[$_p]=${#_t[@]}
|
||||
done
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Single-core Steam affinity is rechecked even if its thread count stayed the same."""
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SCRIPT = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin/droiddeck-session'
|
||||
SOURCE = SCRIPT.read_text()
|
||||
FUNCTION = SOURCE[SOURCE.index('client_single_core_matches() {'):].split('\n}\n', 1)[0] + '\n}\n'
|
||||
|
||||
|
||||
class ClientCoreMaskTest(unittest.TestCase):
|
||||
def matches(self, wanted, tasks):
|
||||
return subprocess.run(['bash', '-c', FUNCTION + '\nclient_single_core_matches "$@"',
|
||||
'test', wanted, *map(str, tasks)], capture_output=True).returncode
|
||||
|
||||
def test_a_mask_change_without_a_new_thread_needs_repinning(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
tasks = [Path(tmp) / str(i) for i in (1, 2)]
|
||||
for task in tasks:
|
||||
task.mkdir()
|
||||
(task / 'status').write_text('Name:\tsteam\nCpus_allowed_list:\t7\n')
|
||||
self.assertEqual(self.matches('7', tasks), 0)
|
||||
(tasks[1] / 'status').write_text('Name:\tsteam\nCpus_allowed_list:\t0-7\n')
|
||||
self.assertEqual(self.matches('7', tasks), 1)
|
||||
|
||||
def test_an_exited_thread_does_not_prevent_checking_live_threads(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
live = Path(tmp) / '1'
|
||||
live.mkdir()
|
||||
(live / 'status').write_text('Cpus_allowed_list:\t3-6\n')
|
||||
self.assertEqual(self.matches('7', [Path(tmp) / 'gone', live]), 1)
|
||||
|
||||
def test_multi_core_masks_keep_the_existing_thread_count_policy(self):
|
||||
self.assertEqual(self.matches('0,1,2,3', []), 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user