wiremod / wire

Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.
http://www.wiremod.com
Apache License 2.0
551 stars 331 forks source link

Likely unneeded performance drop when having addon enabled #2987

Closed wolfestridershooter closed 7 months ago

wolfestridershooter commented 7 months ago

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

Vurv78 commented 7 months ago

https://github.com/wiremod/wire/pull/2576

This PR detours RenderHalos so presumably why there's lag

@stepa2

thegrb93 commented 7 months ago

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

Vurv78 commented 7 months ago

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

thegrb93 commented 7 months ago

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 https://github.com/Facepunch/garrysmod/pull/1590

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

thegrb93 commented 7 months ago

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