Skip to content

Read animation/HUD hot-path ConVars directly instead of by name - #2319

Merged
sunzenshen merged 2 commits into
NeotokyoRebuild:masterfrom
sunzenshen:convar-direct-read
Nov 18, 2026
Merged

sunzenshen merged 2 commits into
NeotokyoRebuild:masterfrom
sunzenshen:convar-direct-read

Conversation

@sunzenshen

Copy link
Copy Markdown
Contributor

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

  • Linux GCC Distro Native (Linux Mint 22.3, GCC 13.3.0)

Linked Issues

sunzenshen and others added 2 commits November 15, 2026 02:35
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.
@sunmachine

Copy link
Copy Markdown
Contributor

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?

@sunmachine

Copy link
Copy Markdown
Contributor

Answered: here

@sunzenshen

sunzenshen commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

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?

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.

@sunzenshen
sunzenshen merged commit b34269d into NeotokyoRebuild:master Nov 18, 2026
11 checks passed
@sunzenshen

Copy link
Copy Markdown
Contributor Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants