Skip to content

[WONTFIX?] Read mp_slammoveyaw directly in the 9-way move yaw - #2237

Draft
sunzenshen wants to merge 2 commits into
NeotokyoRebuild:masterfrom
sunzenshen:anim-cache-slammoveyaw
Draft

sunzenshen wants to merge 2 commits into
NeotokyoRebuild:masterfrom
sunzenshen:anim-cache-slammoveyaw

Conversation

@sunzenshen

Copy link
Copy Markdown
Contributor

Description

CHL2MPPlayerAnimState::ComputePoseParam_MoveYaw builds ConVarRef mp_slammoveyaw("mp_slammoveyaw") on every call. Each construction looks the cvar up by name with CCvar::FindVar, a linear, case-insensitive walk over every registered cvar. The function runs for every player on every usercmd on the server, and every frame for every player on the client, so this one lookup was the largest single cost in a bot match's server frame.

mp_slammoveyaw is defined in shared/Multiplayer/multiplayer_animstate.cpp, which both the client and the server build, and that file already reads it directly. This PR declares it extern and drops the ConVarRef; the mp_slammoveyaw.GetBool() line is unchanged. The value read is the live cvar value, as before: nothing is cached, so changing the cvar still takes effect at once.

Masterkatze identified this lookup cost earlier (unmerged "Cache mp_slammoveyaw" on their fps branch); this version reads the live cvar value instead of caching it once.

How to test

  1. Play any map with bots (or players) and check that legs blend as before while moving in every direction.
  2. mp_slammoveyaw 1 (development-only cvar) still snaps the move yaw while moving; mp_slammoveyaw 0 turns it off again.

Risk

None expected: same ConVar object, same value, no behavior change. ConVar::GetBool reads the parent ConVar's value, and the parent is the one FindVar returned.

Results

Linux dedicated server, Release builds of master (f426c22) with and without this commit, both with the test harness's match markers and a temporary timer around ComputePoseParam_MoveYaw (including its base class call) and around CServerGameDLL::GameFrame. 15 CTG matches per build (ntre_transit_ctg, ntre_rise_ctg, ntre_threadplate_ctg, one per ghost spawn), 30 bots, 1 round, builds interleaved:

master this PR
ComputePoseParam_MoveYaw, per call 9.6 us 0.44 us
its share of server game frame time 16.9 % 0.9 %
server game frame time 1.01 ms 0.86 ms (paired -13.6 %, 95 % CI +-7.0)

A perf profile of the same setup on an earlier master (0707264) put ConVarRef::ConVarRef / CCvar::FindVar under ComputePoseParam_MoveYaw at 13.8-16.4 % of server CPU. The client compiles and runs the same code per frame per player; it was built but not timed.

All 30 matches ended normally with no asserts, and 3 matches on a Debug build (one per map, 30 bots) had no asserts.

CHL2MPPlayerAnimState::ComputePoseParam_MoveYaw built a ConVarRef by
name on every call, so every player's every usercmd on the server (and
every frame on the client) did a linear CCvar::FindVar walk over all
registered cvars. The ConVar is defined in multiplayer_animstate.cpp,
which both DLLs compile, so refer to it with extern instead. The value
read is the same; only the lookup goes away.

Co-authored-by: Mikhail Bogdanov <Masterkatze@users.noreply.github.com>
@sunzenshen sunzenshen added the Animations Animation stuff. Including the syncronizing of animations between client and server based on state. label Oct 15, 2026
Keep the stock SDK code path unchanged outside NEO builds: only NEO
reads the ConVar directly, other builds keep the by-name lookup.
@AdamTadeusz

AdamTadeusz commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

wowee like +50 fps on isolation with 22 bots

(edit) well the fps counter is difficult to read, 50 fps might be a bit much but definitely a significant improvement

@AdamTadeusz

Copy link
Copy Markdown
Contributor

also no ifdef NEOs, but I understand this is a draft pr and imagine you will want to move this into neoplayeranimstate anyway

@sunzenshen sunzenshen added wontfix This will not be worked on and removed Animations Animation stuff. Including the syncronizing of animations between client and server based on state. labels Oct 16, 2026
@sunzenshen

sunzenshen commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

#2244 might actually accomplish the same and better than this, so waiting of the result of that review before deciding what to do with this PR.

(This PR edits hl2mp_playeranimstate.*, which #2244 no longer uses and could even remove from the build.)

@sunzenshen sunzenshen changed the title Read mp_slammoveyaw directly in the 9-way move yaw [WONTFIX?] Read mp_slammoveyaw directly in the 9-way move yaw Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants