Repository navigation
Kirby and the Forgotten Land: frame limits run on the game's own clock, and the 4 fps collapse is gone - #624
Open
intermission88 wants to merge 1 commit into
Open
intermission88 wants to merge 1 commit into
intermission88 wants to merge 1 commit into
Conversation
…k, and the 4 fps collapse is gone The overworld no longer falls off a cliff. Under every frame limit from 20 to 120, Kirby keeps the game's own measured frame timer, one update a frame, and the launcher's limit sets the pace. The fixed-step catch-up that dragged a 30 fps limit down to 4-9 fps for over a minute (GitHub issue igawa6#153) is never switched on, also at 0.1.8's default 60, and guards keep it that way. Root cause, read in main 1.1.0 (and 1.0.0): - [main+0xA76728] points 0x10 into the game's frame timer. Its mode at +0x60 picks the pacing: 2 as shipped (one update a frame, the step measured in 1/60 s ticks, averaged over 4 frames, at least +0x3c ticks a frame), 0 a fixed 1/60 s step. - The FPSLocker Warehouse row these limits used set the mode to 0. At 30 fps that is two updates a frame, twice the game's CPU work, and a late frame is caught up with up to 10 updates and no drawing (+0x20, checked at main+0x532FB8). Once the updates outlast 16.7 ms every frame is late: 10-11 updates per drawn frame, 210-325 ms frames, the GPU idle at 5 ms. Fixes: - game.tsv: the mode-0 write is replaced by one write of the least wait of the game's own mode (constant_i32 +0x2c = 1; 2 as shipped, the game's 30 fps). The dynamic resolution budget rows stay. - The default stays the owner's 60 (0.1.8); with the game's own timer it no longer collapses. On the Thor a limit is also evener on screen than Game owned: 2,890 of 3,288 frames uneven under Game owned, 3 of 4,490 at 30. Keeping it fixed: - peanuts/tests/test_profile_fpslocker.py parses every profile's fpslocker rows with the host's own parser (one refused row makes the host drop the whole set) and fails if Kirby's rows write the timer mode or the catch-up bound again or lose the +0x2c row. - dm/tools/log_rules.tsv: game-catchup-stall names such frames in a player's log (a [longframe] of 200 ms or more, the GPU idle, nothing loading, the game's threads waiting on each other), in log_digest, issue_digest and the launcher; unit-tested on the real collapse line. - docs/reference/frame-rate.md: a new entry, "A fixed-step mode chosen by a frame limit catches up until the frame rate collapses", with a review rule for Warehouse writes that change a timer mode; the symptom index updated. - Kirby's note: the frame timer, its addresses, where to find them in a new main build, and the runs below. Measured on an AYN Thor (Snapdragon 8 Gen 2, Turnip 27.0.0 R2, the middle cores held at 1.79 GHz by a clock tune), a build of main with this profile: - 30 (that build's default, after a settings reset): 29.8 fps in almost every 5 s window over 2.6 minutes (overworld, levels, movies), p95 33.6 ms; the old rows collapsed to 4-9 fps in the same area. - 20: 19.7-20.1 fps, p95 50.3 ms. 40: 39.1-40.0 fps, p95 25.0 ms. - 45 (43.2-45.2) and 60 (reached) on an earlier build with these rows; the game's speed normal by eye at every limit. Known issues, not from this change: - 60 in busy levels is bound by the CPU (47-51 fps at 1.79 GHz, 55-57 at the stock clocks near 84 C). The Thor's kernel pauses its fast core while idle (core_ctl min_cpus 0), so the replay thread meant for it runs on all cores, the small ones included. - The overworld's round trees are drawn nearly black on Turnip; the same with DM_VK_PUSH_DELTA=0 and DM_VK_UBWC=0. - Not run: the system driver, 90, a session of 10 minutes or more, the 8+ Gen 1 phone of igawa6#153. Recommended on a Thor: 60 (the default) where the CPU clocks allow it; 30 for an even, cool picture with a clock tune; 40 or 45 in between.
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The symptom. Under a frame limit, Kirby held its rate for a minute or two and then fell off a cliff in the overworld: 4-9 fps for over a minute, whole frames of 210-325 ms, the GPU idle at 5 ms a frame. GitHub issue #153 reported it on a Snapdragon 8+ Gen 1 (3-6 fps at the 30 and 60 limits); it also happens on an AYN Thor at 30. The profile then started the game Game owned to avoid it; since 0.1.8 it starts at 60 (the owner's call) with the same mode-0 row, so every player now starts in the mode that collapses.
The cause (read in main 1.1.0, and the same in 1.0.0).
[main+0xA76728]points 0x10 into the game's frame timer. Its mode at +0x60 picks the pacing:+0x3cticks (2 = the game's 30 fps)+0x20(10) updates and no drawing (checked atmain+0x532FB8)The FPSLocker Warehouse row the limits used (
zero_i32at+0x50) set the mode to 0. At 30 fps that is two updates a frame, twice the game's CPU work, and once the updates outlast 16.7 ms the catch-up never ends: 10-11 updates for each drawn frame. That is the collapse.The change (
dm/games/01004D300C5AE000/game.tsv, one profile, no code):constant_i32 0xa76728/0x2c 1 1:1(2 as shipped, 1 lets the game run to 60). The host's frame limit sets the pace and the game keeps one update a frame at every rate. The dynamic resolution budget rows stay.Keeping it fixed (so this does not come back, here or in another game):
peanuts/tests/test_profile_fpslocker.py: it fails if Kirby's rows write the timer mode (+0x50) or the catch-up bound (+0x10) again or if the+0x2crow goes missing. It also parses every profile'sfpslockerrows with the host's own parser (fpslocker_rows.h), because one refused row makes the host drop the whole set (invalid reviewed rows; no memory writes applied) and a limit then runs without any of the game's writes. Checked against both mistakes: aconstant_i32value written2instead of2:1, and the Warehouse's mode-0 row added back.game-catchup-stall(dm/tools/log_rules.tsv, read bylog_digest.py,issue_digest.pyand the launcher): a[longframe]of 200 ms or more with the GPU idle, nothing loading and the game's threads waiting on each other. A player's log of this collapse, in any game, now says what it is and links the entry. Unit-tested against the real collapse line, and against loading frames and small hitches that must not match.sdivby 16,666,666 ns, an update count compared to a cap, drawing skipped while it catches up).nso_fnmap.pymaps them.Docs: the frame timer, its addresses and the runs in Kirby's note; a reference entry, A fixed-step mode chosen by a frame limit catches up until the frame rate collapses, with the symptom index.
Fixes the cause of #153 (not yet run on that phone; the reporter is welcome to confirm).
Checked
peanuts/tests/test_profile_fpslocker.py(every profile's rows, the Kirby guard) andtest_log_digest(the new rule),test_fpslocker_rows,test_fpslocker_plan,test_android_frame_rate_caps,test_env_switchesand the othertest_android_*(withtest_android_logdigest, the launcher reading the same rule table on the JVM) pass;peanuts/scripts/check-profiles.sh 01004D300C5AE000passes.test_docspasses.test_android_packfindfails on the Mac's own Python 3.9 (type | type), unrelated.a6ce40dc…), the middle CPU cores held at 1.79 GHz by a clock tune.A build of main 0.1.7 with these rows only (that build started at 30), Game settings reset to the defaults first:
The game's speed is normal by eye at every limit. The longest frames (130-180 ms, once a run) are an area loading 50-160 MB of textures.
Before and after, the same overworld at 30:
Also run on an earlier build with these rows: 45 (43.2-45.2 fps over 3.5 min, about 60 °C) and 60 (reached, normal speed; 47-51 fps in busy levels at 1.79 GHz, see Known issues).
Known issues (not from this change)
core_ctl min_cpus 0, stock clocks too), so the replay thread meant for it runs on all cores, the small ones included. A launcher fix of its own comes separately.DM_VK_PUSH_DELTA=0,DM_VK_UBWC=0); open.[RED] vk: shader 7fe2de4f7a52eac0 binding 261: texture ID 1497 has no view of shape 0x2line once a run; unrelated to the timer.Recommended
Docs
docs/reference/frame-rate.mdentry;python3 dm/tools/docs_symptoms.pywas runmain(0.1.8)