Repository navigation
perf(fp): run skeleton modifiers on the idle frame, not per physics frame - #123
Merged
Merged
Conversation
…rame Every Skeleton3D defaults to modifier_callback_mode_process=PHYSICS, so the GDScript modifiers (DogRig/CatRig on every animal body, the hero's strike pose and head look, the T0 conversation look) ran once per physics frame and were paid again for every physics catch-up step a slow web frame absorbs. The fp animation mixers are all hand-advanced on the idle frame already; run the modifiers there too (IDLE), so a rendered frame pays them exactly once. Pinned by a mode assert in the animals, cats, people-prewarm and player suites. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Automated reviewNo new findings on the 10 changed files (gdlint, complexity, TODO policy, dead code). Run |
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
Every
Skeleton3Ddefaults tomodifier_callback_mode_process = PHYSICS(Godot 4.7), so the game's GDScriptSkeletonModifier3Ds —DogRig/CatRigon every animal body, the hero's strike pose and head look, the T0 conversation head look — ran once per physics frame at 60 tps. The fp layer animates entirely on the idle frame (all mixers areANIMATION_CALLBACK_MODE_PROCESS_MANUAL, advanced by hand), and the physics server is parked on the web (#89) — but parked physics frames still tick, so the modifiers kept paying per-tick, and were paid again for every catch-up step a slow frame absorbs (up to 2 on web after #84). The day-10 tick-frame attribution puts ~11 ms of the ~45 ms street_tick p50 in exactly this line (round4/web-perf-budget v3.1).The fix is one line per attach site:
modifier_callback_mode_process = IDLE— modifiers run on the idle frame with the hand-advanced mixers, exactly once per rendered frame, immune to catch-up multiplication. Modifiers use real deltas (dog wag pace, LookAt duration), so behavior is unchanged beyond sub-frame timing.Attach sites
traffic/people_pool.gd— every people body at build (the T0LookAtModifier3Dhead look)animals/dog_bodies.gd—DogRiganimals/cat_bodies.gd—CatRigplayer/hero_strike_pose.gd—StrikePoseplayer/hero_look.gd— hero head/neckLookAtModifier3DsTests
fp_kit.check_modifier_modes(fails, root): sweeps the scene for anySkeletonModifier3Dand asserts its skeleton is on the IDLE mode — a future physics-callback modifier fails the suite. Wired into fp_animals (12 modifiers swept), fp_cats (16), fp_player (10).FP_ANIMALS_TEST,FP_CATS_TEST,FP_PEOPLE_PREWARM_TEST,FP_PLAYER_TESTall PASS;tools/gate.sh quickand pre-commit green.Perf
Native bracket measurement (fixed-fps 60, parked server): 48 modifier-bearing skeletons cost 0.275 ms/physics-frame vs 0.172 ms bare — the modifier share is real and scales with characters on screen; on wasm (GDScript callbacks ~5-10× slower) at day-10 counts this is the ~5-6 ms/physics-step line the attribution measured, double-paid on catch-up frames.