WIP: perf(thread): on the Steam Deck, a starved guest thread takes a core after 30 ms, not 1 s #1860
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1860
Loading…
Reference in a new issue
No description provided.
Delete branch "omgitsgela/Longshot:deck-vcore-starve"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On the Steam Deck, a game thread that has been waiting for a CPU core can wait a full second before it gets a turn. In Castle Town that shows up as hitches during camera turns. This makes 30 ms the automatic default on the Steam Deck's own hardware, while every other PC keeps Horizon's 1 second rule. A normal Deck build gets the improvement with no build flag, and
HOS_VCORE_STARVE_USstill overrides it.What changed
host/hos_thread.cvc_acquire: the starvation default now comes from the renderer's existing device name.Custom GPU 0405(Deck LCD) andCustom GPU 0932(Deck OLED) get 30 ms; every other device gets 1 s. The renderer is asked afterhos_renderer_wait(), so its device facts are ready, and the choice is logged once.HOS_VCORE_STARVE_USstill overrides either default.nx2/build.py: theLONGSHOT_DECKbuild flag is gone. A normal Deck build no longer needs it.tests/test_vcore_escape.py: the fixture gives the vcore block the Deck's own renderer name for one profile and a desktop GPU's for the other, checks the LCD, OLED and desktop names, and runs both timing profiles through the runtime default.Why automatic on the Deck
On machines where the game's threads land on real cores, chronic starvation means something is wrong, and 1 s is the right diagnostic. The Deck is the hardware where six guest cores really share four physical ones, so tens of milliseconds of waiting is the normal case, not a bug sign. Asking the renderer which GPU it is uses the same device facts that already set the game's platform defaults, so there is no new hardware probe and no build flag for players to discover.
Measurements (Deck LCD,
rt-kbd1527bc7f97a, Castle Town center save, full-speed turn protocol, 2x2 counterbalanced: 30 ms / default / 30 ms / default)Both 30 ms boots beat both default boots. Median FPS gain in town is about 1 fps (20.2 to 21.6 idle); the gain is in the tail. Zero escapes (two threads on one core, #1929) in any arm.
This table is the threshold experiment with
HOS_VCORE_STARVE_USinjected. The compiled default's own A/B is the next run, below.Tonight's A/B
main(latest +0).mainintodeck-vcore-starve, then build it (latest +1860). Both arms must use the same save, settings and warm caches.HOS_VCORE_STARVE_USunset in both arms.vcores: Steam Deck hardware: ... 30 msline should appear only in the +1860 arm.docs/tested/rows and update this description.Testing
python -I -B tests/test_vcore_escape.py --cxx g++: 4× ok (both profiles, each with the override too).tests/run_all.py test_vcore_escape: pass.Still to test: the two Deck arms in Tonight's A/B, and the Windows build.
Risks
On the Deck, a thread that has waited 30 ms may take a core from a higher-priority holder. The measurements show no escapes and fewer long waits. Every other PC keeps Horizon's 1 s rule, and
HOS_VCORE_STARVE_UScan put it back. Rollback is the revert; there is no switch or saved setting involved.Tested in game: Steam Deck LCD (VanGogh, RADV Mesa 26.2, SteamOS), rt-kbd152 build
7bc7f97a: the exact vc_acquire starve path ran at 30 ms for 4 full Castle Town boots (2x2 counterbalanced vs the 1 s default, Angela's market-center save, scripted full-speed turns): waits over 20 ms 16,237/8,059 ms per boot fell to 5,732/5,773 ms, idle frames over 50 ms 41% to 23%, zero escapes in any arm, no hangs or corruption. The PR build's own Deck-define arms (rt-vcore vs the explicit 1000000 override) follow as a PR update.Let's test this widely if this is something that can improve for every, and set a good default. Ideally we don't need a Deck specific flag
@Beanstalk
@HumanBean approval of
61f7751recorded. This diff touches sensitive paths, so a second member ofBigBeansmust approve it too.Beanstalk test farm · an earlier run: commit
2b959bd(the newer results are in a comment below)Commit
2b959bd· approved by HumanBean (reviewed) · dashboardStarted at 2026-11-20 18:19 UTC.
Estimate: done in about 45 min, from the queue and the testers online now; some jobs can't start yet.
anysteamdeckmarket-turns· frame time p99 (ms), main → PR at each levelHOS_VCORE_STARVE_US=1000000(reference)HOS_VCORE_STARVE_US=30000anysteamdeckWhy it failed
any:market-turns · HOS_VCORE_STARVE_US=1000000screenshot.max_diff:limit 0.1any:market-turns · HOS_VCORE_STARVE_US=30000screenshot.max_diff:limit 0.1Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
any, report 1:Insufficient frame-time evidence for 6 required comparison(s). See rule results. a step ran out of time: timeout: a new save did not get into play within 900 s (the state is boot) (then the game was in boot, on no known map)What was tested
What will be tested · AI plan (
gpt-6.1-terra)The farm will compare the 30 ms and 1 s runtime starvation thresholds in Castle Town on an available PC and a Steam Deck, using idle measurements and scripted camera turns. Each threshold runs on main and the PR; frame-time tails, whole-run hitches, escape logs and screenshots are checked for regressions, hangs or corruption. Gameplay takes about 25 minutes per tester, with build timing measured separately. The farm cannot set the new Deck build-time flag, so this tests the runtime override rather than verifying the compiled 30 ms default or the fixture.
1000000or30000.Measurements on `any`, for the PR description
Verdict: fail on any (2 reports):
market-turns screenshot.max_difffailed.Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Steam Machine (RADV NAVI33), 26.1.99AMD Custom CPU 1772, 16 GB RAMScene: market-turns, from a new save; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-turns: 1 game start a side, idle 40 s after 5 s warm-up, after-turns 20 s after 0 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)89c3d212b959bdHOS_VCORE_STARVE_US=1000000· hitches over 50 ms in the whole runHOS_VCORE_STARVE_US=1000000· idle · frame time (p99) (ms)HOS_VCORE_STARVE_US=1000000· after-turns · frame time (p99) (ms)HOS_VCORE_STARVE_US=1000000· forbidden log linesHOS_VCORE_STARVE_US=30000· hitches over 50 ms in the whole runHOS_VCORE_STARVE_US=30000· idle · frame time (p99) (ms)HOS_VCORE_STARVE_US=30000· after-turns · frame time (p99) (ms)HOS_VCORE_STARVE_US=30000· forbidden log linesBuild times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
89c3d212b959bdFlags and settings
HOS_VCORE_STARVE_US1000000,30000As Markdown for the PR description:
The testers' hardware
anyNVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAManyAMD Steam Machine (RADV NAVI33), 26.1.99AMD Custom CPU 1772, 16 GB RAMRebased-merge with latest main: head is now
2b959bd6(merge of89c3d21e, nightly-612: #1782 lift SSE fast paths, #1848 capture-buffer destroys threaded, #1158 VRAM given back, #1814 OptimizeChangeBank turn hold, #1850 ci). Fixture still 4× ok on the merged tree (g++, both profiles). This merged build is what went onto the Deck for the first live play test; no conflicts, no changes to this PR's own content.@Beanstalk please A/B the starvation threshold on non-Deck tiers, on this head
2b959bd(the compiled default stays 1 s on every non-Deck build; the arms differ only by the env):HOS_VCORE_STARVE_US=30000. Two boots each, interleaved A/B/B/A.HOS_FPS_TIMINGframe trace), frames over 50 ms during idle and during turning, and the frame-time median.Deck results already in this PR's Measurements (Castle Town center, 2x2 counterbalanced: waits over 20 ms 16,237/8,059 -> 5,732/5,773 ms per boot, idle over-50 ms tail 41% -> 23%); the tiers here are the missing half.
@omgitsgela only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@Beanstalk
@HumanBean approval of
2b959bdrecorded. This diff touches sensitive paths, so a second member ofBigBeansmust approve it too.@Beanstalk
/review
Recommendation: Request changes. The measured threshold is not enabled by any normal Deck build path, so Deck players get the old default unless they discover and set a build-time variable themselves. The threshold looks promising in one Deck experiment, but this branch's shipping behavior and its wider scheduling costs remain unmeasured.
The change lowers the starvation threshold only when the builder receives LONGSHOT_DECK=1, and adds a two-profile scheduler fixture. The runtime override experiment suggests fewer long waits, but the proposed build-time gate does not reach ordinary Deck installations and adds a hardware-specific build profile rather than choosing a default for the machine running the game.
Does it help: Unproven for this PR as shipped. On a Deck LCD, two interleaved runtime-override arms reported waits over 20 ms of 5,732/5,773 ms versus 16,237/8,059 ms and whole-protocol frames over 50 ms of 47%/42% versus 52%/55%. These are encouraging, but are not main versus this head's compiled defaults; FPS 1% lows and p99, other scenes and the cost to higher-priority work are not reported. Farm runs are queued, and explicitly do not test the compiled default.
Other systems: The scheduler is shared by guest threads and all platforms: a 30 ms boost can delay higher-priority work, including in other scenes and on other small-core machines. Ordinary non-Deck builds retain 1 s; a binary built with the flag retains 30 ms even if moved to another machine. Deck OLED, other handhelds, Windows/Linux and other CPU tiers need evidence for any expanded default. No save, audio, GPU or renderer interface changes are apparent.
Switches: LONGSHOT_DECK is a new build-time variable, unset by default, with 1 selecting 30 ms; it is not set by the normal build paths. HOS_VCORE_STARVE_US remains a runtime override, including 0 to disable the boost; its compiled default becomes 30 ms only in that profile, otherwise 1 s. The profile's default and distribution are not yet justified by measurements.
Reviewed:
2b959bd67fagainst89c3d21ea1: Read tests/test_vcore_escape.py, base AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md and the PR template in full; read the entire diff. The tool truncated host/hos_thread.c and nx2/build.py, so their unchanged portions were skimmed rather than read in full; inspected the changed hunks and scheduler fixture. docs/review-checklist.md does not exist. No generated files or translations changed. Tooling's separate AGENTS.md was not available through the repository file reader.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Testing: Author reports four fixture passes and a Deck runtime-override experiment; the farm has no reports yet. No code was run in this review. Measure main versus head defaults, including frame-time tails and priority-sensitive scenes, and verify the real installer/build path; report the full test suite and platform builds.
Overlaps and merge order: Open #327 also changes virtual-core affinity and migration; coordinate scheduler review and retest after whichever lands first. Open #1875 changes virtual-core availability during zstd and targets the same Deck/market contention; compare combined results and retest after merge. Neither is necessarily a duplicate.
-# Automated code review by IssueBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -590,0 +594,4 @@# turn (measured 2x2 on an LCD Deck, Castle Town market, full-speed turns: waits over 20 ms 16,237 to 5,732 ms a boot,# idle frames over 50 ms 41% to 23%, no escapes in either arm; https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1477).# HOS_VCORE_STARVE_US overrides either way. Unset: the 1 s Horizon rule, as everywhere.DECK = os.environ.get("LONGSHOT_DECK", "") == "1"What sets this for a player's normal Deck build? No other repository reference sets it, so an ordinary install/update keeps the 1 s default and never receives the measured improvement; a binary copied elsewhere also keeps the Deck policy. Please select the appropriate default at runtime, or wire and test a supported build path that actually enables this profile.
Beanstalk test farm
Commit
20b4262· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.WIP: perf(thread): a Deck build lets a starved guest thread take a core after 30 ms, not 1 sto WIP: perf(thread): on the Steam Deck, a starved guest thread takes a core after 30 ms, not 1 sThe build-time flag is gone. The starvation default now comes from the renderer's existing device facts: the renderer already names the GPU it runs on, so
Custom GPU 0405(Deck LCD) andCustom GPU 0932(Deck OLED) get 30 ms, and every other device keeps Horizon's 1 s.HOS_VCORE_STARVE_USstill overrides both. Head is20b4262c.The test fixture now gives the vcore block the Deck's renderer name for one profile and a desktop GPU's for the other, and checks the LCD, OLED and desktop names.
tests/test_vcore_escape.pypasses under g++.Tonight's A/B is written into the description:
then-latest mainas the+0arm.then-latest mainintodeck-vcore-starveand build the+1860arm.HOS_VCORE_STARVE_USunset in both arms, same save and warm caches, two runs per arm interleaved.vcores: Steam Deck hardware: ... 30 mslog line should appear only in the +1860 arm.The farm's
anycell did not fail on this code: its report is a tester sandbox error (git rev-parseand/dev/nullpermission). The two Steam Deck cells are still building. After the A/B, the farm can be rerun against the real default instead of an env override.Changed-file check on the pushed head
20b4262c:tests/run_all.py --changed origin/mainis 20 passed / 5 failed / 2 skipped. All five also fail on clean main here:test_crash_record,test_dev_packs,test_profiling_mode,test_slow_frames, andtest_vcore_mask0(the last one also fails to compile on main with g++).tests/test_vcore_escape.pyitself is green.No Deck work was run from here; the current
latest +0build is untouched.Closing this as dropped.
Tested on a clean latest-nightly A/B on the Steam Deck LCD:
846e5399(nightly-649) against21efecc24(nightly-649 plus this change, versionnightly-649 +1860, source3a4d2b76), Castle Town center save (Market_Child), scripted camera turns and forward/back movement, GPU and CPU clocks pinned, two runs per arm at 100% render and one at 50%.HOS_VCORE_STARVE_USwas unset; the 30 ms value was the compiled Deck default.The rule does what it says to the scheduler: 509/454 starvation grants against 1/1, and the longest single core wait fell from 1000.8/1000.3 ms to 107.2/415.8 ms. But the frame-time tail got worse, not better:
It trades a rare one-second stall for more frequent 50 ms+ stalls during play, which is the wrong direction for the camera-turn hitches this was meant to fix. The only positive was an idle-only 50% arm (28.2 against 26.6 fps, >50 ms 1.5% against 4.7%), and it did not survive movement.
No further version will be pushed; the branch stays for history. If this is revisited, the narrow worth testing is a steal that only takes cores from holders below the frame-critical priorities, or only for loading/streaming waiters, and it needs the same whole-protocol p99 and >50 ms scoring.
Record note: the pushed head
20b4262cstill gates the 30 ms value behind theLONGSHOT_DECKbuild flag inhost/hos_thread.c; it does not contain the renderer device-name default described above. The A/B above tested that build-flag implementation.Thanks to HumanBean, BeanBot and the Beanstalk testers for the review and farm runs.
Pull request closed