wiremod/wire

Likely unneeded performance drop when having addon enabled

wolfestridershooter opened this issue · 5 comments

Describe the bug:
While trying to find what was causing me performance issues in Garry's Mod by using Addon hooks Lag Finder I found this:

Identifier  -----------------------------------------------  Impact      Executions     Mean t/f        Max time
 Event "PostDrawEffects", hook "RenderHalos"                 04.78%      2526           595.495us       2272.00us
  in "lua/wire/client/cl_wirelib.lua" (lines 244 to 248),
  found in Workshop addon « Wiremod »

Sure enough when I disabled Wiremod I gained FPS in an idle scenario. My guess is that this code renders the Halo effect that shows when you look at a wire entity, but if we have no wire entities on the map why are we running this? I don't know maybe I'm completely wrong and there is a good reason why it's being done.

To Reproduce
Steps to reproduce the behavior:

  1. Start a new game
  2. Do nothing
  3. Lose FPS

Expected behavior:
To not lose FPS when not using Wire entities

#2576

This PR detours RenderHalos so presumably why there's lag

@stepa2

detouring it won't produce lag... It's just calling https://github.com/Facepunch/garrysmod/blob/87aa68cb8da3d70e6e7265bc61ca222c55e3f8e5/garrysmod/lua/includes/modules/halo.lua#L147 which is historically known to be a very costly function

Detouring will absolutely produce lag.. especially since it runs hook.Run beforehand, and the hook library is not as fast as it could be.

Maybe the addon he's using is just marking wire as the cause of the halo lag, but still, detouring will add overhead esp to a render hook

The script is just profiling hooks so yeah, it's identifying the wire hook which calls garry's hook, to be the culprit. This PR tried to improve its performance but didn't work Facepunch/garrysmod#1590

It's not wire's problem that gmod's halo system is very costly.

I think there's a convar to disable halos btw. Don't remember tho. Or it's just to disable the physgun halos.