Open EstevanTH opened 7 years ago
I did not think to look there, thanks!
Ohh I know why this is done serverside, basically!
It is because the event "PlayerTick"
is predicted!
Widgets would not work in single player if the hook was not added serverside in single player.
Is this hook added on SP as well as MP, both serverside and clientside, for easier compatibility? I mean, in order to avoid the necessity to make 2 different codes for SP and MP.
If it is never run on the client, why is there a hook.Add( "PostDrawEffects", "RenderWidgets", ... )
in the module and why is everything shared according to the wiki? 😮
I think that the widget module is included in garrysmod\lua\includes\init.lua
, both serverside and clientside. Am I wrong or something?
Also I could not wait to publish my new addon Widgets Disabler (more CPU power!) 😄
Sorry, I mixed it up with another library.
That is indeed heavy.
@mcNuggets1 Just use an addon that removes the widget hook when it's not in use; the problem has been around since GM13 came out
Details
Hi Rubat, hi Willox. I do not really know how relevant this performance issue is, but I'm going ahead. The serverside hook
"TickWidgets"
(event"PlayerTick
"), defined in widget.lua at line 149 really is CPU expensive.The quoted console log is generated by my Addon hooks Lag Finder. It shows that about 30% of the frame time is dedicated to handling widgets. The server runs the gamemode University RP, derived from DarkRP, derived from Sandbox. It runs with me and 127 bots. The tickrate is 20. The CPU is AMD K10 @ 2.5 GHz.
I do not think I am running any widget and bots do not need them anyway.
Steps to reproduce
-game garrysmod
. Adjust the tickrate if you'd like.gamemode base
,maxplayers 0
,bot_zombie 1
andmap gm_flatgrass
.bot
127 times, take your time to avoid any crash.net_graph 4
and take a look at thesv
value for a while (this is the current server FPS value).lua_run function widgets.PlayerTick() end
sv
value again. In the same conditions as my test, that makes +42% of performance. In the base gamemode, that must be much higher.You can install my Addon hooks Lag Finder if you are not convinced about the problem.
A few ideas to solve this
Well, I am not used to widgets. That said, I still understand the comments that explain the usage of widgets. I'm providing ideas to solve this, but I feel dumb because I can't find anything really good.
Entity:IsWidget()
is obviously not a good idea here).Momo ❤️