Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cvars.AddChangeCallback spam performance issues #21

Open
xaviergmail opened this issue Jul 6, 2019 · 6 comments
Open

cvars.AddChangeCallback spam performance issues #21

xaviergmail opened this issue Jul 6, 2019 · 6 comments

Comments

@xaviergmail
Copy link

fprofiler

I'm currently working on something else and I don't have the time to make a PR to improve this, but it could definitely be worth having a look at.

@SupinePandora43
Copy link

@xaviergmail what is on screenshot?! (which utility)

@xaviergmail
Copy link
Author

xaviergmail commented Jul 7, 2019 via email

@xaviergmail
Copy link
Author

I've moved the cvars.AddChangeCallback calls over to the AddConvar helper function and the difference is night and day. This SetNetworkData function seems like it's doing a lot of heavy lifting for no reason, and does so in a render hook.

@MuckerMayhem
Copy link

What was the change you made exactly? I'm looking to fix this locally for our server to tide us over until an official fix can be pushed, if you have an example I can probably work of of that.

@xaviergmail
Copy link
Author

@MuckerMayhem

Remove the cvars.AddChangeCallback function call from from lua/stormfox/framework/sh_network.lua inside StormFox.SetNetworkData and move it to

lua/stormfor/lib/sh_convars.lua

	local function AddConVar(str,default,helptext)
		StormFox.convars[str] = true
		if ConVarExists(str) then return end
		CreateConVar(str,default, { FCVAR_REPLICATED, FCVAR_ARCHIVE }, helptext)
		cvars.AddChangeCallback(str, function( convar_name, value_old, value_new )
			StormFox.SetNetworkData("con_" .. convar_name, value_new)
		end,"SF_Netupdate-" .. str )
	end

Sorry I can't provide a proper diff right now. Also I don't know if this has any unwanted side effects, but I don't seem to see any right now.

@MuckerMayhem
Copy link

Muck appreciated, I think I've got it in right.

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

No branches or pull requests

3 participants