| closedPcvars |
| Started by Tank on 07-09-2008, 09:40 AM |
Threads: 59
Joined: Jan 2007
I've noticed a lot of you people are using PCVARS. I assume that's the way to go when registering CVARS?rnrnCan anyone explain why using pcvars over the original method of creating a cvar?
Threads: 103
Joined: May 2005
from the amxx wiki:nn
As of AMX Mod X 1.70, you can cache "cvar pointers". These are direct accesses to cvars, rather than named access. This is a critical optimization which is dozens of times faster.
Threads: 59
Joined: Jan 2007
The difference is instead of passing a "cvar name", you pass the "cvar pointer", which is a direct memory access rather than a string lookup.rnrnI did read the Wiki but I didn't really get what it said. So I guess the plugin is loading faster with PCVARS then just CVARS?rnrnAnd if so I will do smart changing all the plugins Im using to carry PCVARS instead of CVARS?
Threads: 103
Joined: May 2005
yeah you should ALWAYS use pcvars where possible..nnbasically it knows exactly 'where' the cvar is when you make a reference to it.. instead of going thru the whole list of cvars on a server (which with default cvars, and all those added by plugins.. can be 100s of cvars)
Threads: 42
Joined: Sep 2007
the best (and fastest) solution I think is:rnusing pcvars , but in high-freq. event like client_damage() or client_death() it is better to "cache" the value of an cvar in an normal var of plugin so it is not needed to read via get_cvar_.. and not needed to read via get_pcvar.. !rnrnonly vars that change often shall be read with get_cvar_.. or (BETTER!) get_pcvar_.. !!
Threads: 54
Joined: May 2005
When a server first loads up on map change, startup, etc ... it "stores" all of the binary code necessary to make the game work... AMXX is just another, and technically the "last" layer of code that gets "stored" to memory (your RAM). When it gets stored each and every little "chunk" gets placed in a certain location, never "moves" from that location and that location then has a unique identifier...n nThis gets REALLY technical but to correctly answer the question you have to understand how it works...n nWhen you make reference to a "cvar" in your code the processor must then go and "search" for this cvar stored in memory somewhere and the more memory the more time it could potentially take to retrieve this data.n nDoing this just ONCE is fine, and in fact in both scenarios you do have to make atleast one initial search... but say you wanted to reference something a number of times... could be hundreds or thousands in any given hour... running that same search over and over all those times add up to used processing time ... granted we are talking milliseconds, over time it DOES add up.n nA "p"cvar is a POINTER. A pointer is reference to a LOCATION within memory containing information. By getting and storing and then using a pcvar value you are making the search ONCE and then thereafter able to directly get the information directly from memory from the specific location you stored in the initial search.n nThink of this analogy... you need to find a website that sells foobars. But who sells foobars?? You "google" it ... and lo and behold... www.foobarswebsite.com sells foobars. So you buy and order some foobars and be on your way and close out. Now 2 days later you want some more foobars. What would be more effecient?? Going to "google" and finding the site again... or during your intial search you "remember" the site url.... therby SKIPPING the "google" portion and going directly to where you want to go...n nThis is the nature of POINTERS and therefore the reason why it is SUGGESTED that you convert to using get_pcvar_ when possible as the overall reduction in processing greatly increases the potential performance of the plugin...n n
I've noticed a lot of you people are using PCVARS. I assume that's the way to go when registering CVARS?n nCan anyone explain why using pcvars over the original method of creating a cvar?n nIn either case you are always still "creating" a cvar.. it simply then a matter of how you will then access the information attached to that cvar...
Threads: 12
Joined: Aug 2006
nice explain tat i got it
Threads: 42
Joined: Sep 2007
a short video that views how to change(recode) an plugin to pcvars using:rnhttp://spitzenserver-de-web.systemon.de/tutorials/amxmodx_tunning.html
Threads: 15
Joined: Mar 2007
Interesting. For some reason I thought that retrieving a cvar with the pcvar commands would be the original cvar value loaded on map change / server start even if it was changed when a server was live. Looks like I have some refining to do. XD

