garrysmod-requests icon indicating copy to clipboard operation
garrysmod-requests copied to clipboard

Implement optimization for `CCvar::FindCommandBase`

Open RaphaelIT7 opened this issue 10 months ago • 1 comments

Details

Implementation: https://github.com/Source-Authors/Obsoletium/compare/master...RaphaelIT7:obsolete-source-engine:patch-8 I made this optimization a while ago & implemented it into holylib which showed up to a ~40x(normally around ~10x) performance improvement in my cases without causing any issues.
The current implementation has the issue that it becomes slower with each added convar which is solved with this change. FindCommandBase isn't a huge function and is not called frequently, so it won't really be noticeable, but for calls like GetConVar_Internal it will definitely be a noticeable improvement.

RaphaelIT7 avatar Jan 20 '25 07:01 RaphaelIT7

Just to mention it, it seems like CS:GO does already have something like this. Maybe the 64x of Gmod also already has this & only 32x is missing it? -> https://github.com/perilouswithadollarsign/cstrike15_src/blob/master/vstdlib/cvar.cpp#L615-L632 CS:GO uses CConCommandHash m_CommandHash which probably works the same way, if not possibly even better than the method I had implemented.

RaphaelIT7 avatar Sep 23 '25 08:09 RaphaelIT7

~~I do think that this will break binary modules though, by removing GetCommands methods from ICvar.~~

Nevermind, VPhysics relies on those, so we got to keep it.

robotboy655 avatar Sep 23 '25 13:09 robotboy655