Repository navigation
Read animation/HUD hot-path ConVars directly instead of by name - #2319
Conversation
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 NEO refers to it with extern instead; other builds keep the by-name lookup. The value read is the same. Co-authored-by: Mikhail Bogdanov <Masterkatze@users.noreply.github.com>
The round-state HUD built a ConVarRef for sv_neo_bot_cmdr_enable on every paint and per drawn player row, which searches the console variable list by name each time. The ConVar is defined in shared code compiled into the client, so read it through an extern instead, as neo_hud_context_hint.cpp already does.
|
Is it clear why the original system did not do this? Did it seem to you like it was an oversight or was it doing something we now miss by going straight to the source? |
|
Answered: here |
To recap, it seems the original system is guarding against the original mp_slammoveyaw not being defined, but the way that we use it, it appears it is always available. The other usage for checking if the bot command system is enabled for HUD rendering was an unnecessary copying of this pattern when we for sure know that the ConVar will exist. |
|
Crud, I forgot to add the co-author tag for @Masterkatze during the squash merge, for credit for the original frames per second improvement discovery. 🥲 (added to Assignees) |
Description
Two places looked up a console variable by name on a hot path, which searches the list of all console variables each time: the player animation update (
mp_slammoveyaw, once per player per update) and the round-state HUD (sv_neo_bot_cmdr_enable, once per HUD paint and once per player row). Both variables are defined in the same library as the code that reads them and are already read directly elsewhere in it, so each lookup is replaced by a direct read of the same variable.Other lookups by name were left alone: they are on rare paths, or the variable lives in the other library or the engine.
Toolchain
Linked Issues