Raised This Month: $32 Target: $400
 8% 

[TUT] Modules and efficient scripting


Post New Thread Reply   
 
Thread Tools Display Modes
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-30-2009 , 11:07   Re: [TUT] Modules and efficient scripting
Reply With Quote #41

Quote:
Originally Posted by Hawk552 View Post
If it takes less time for all of the equivalent functions to be found and then executed from front to back with identical code inside them, then you can consider that forward faster than the one you're comparing it to. Basically, what I'm saying is this:

As far as I know, AMXX keeps a "lookup table" of all public functions in each active plugin. I think it would be faster to go through this and look for "client_PreThink" in each plugin than it would be to navigate through the registered forwards in FakeMeta. I could be wrong, though; one reason being that multiforwards have to scan through each plugin and each function in them, which I would assume becomes more and more trivial as FM_PlayerPreThink gets registered more times. FM_PlayerPreThink, however, has to execute a separate forward for each plugin registering it.

I don't know the internal workings of AMXX's forward handling well enough to really say with total certainty which would be faster. What I've posted is just a guess. It's also hard to benchmark them against each other. As I said before, a better benchmark may be to check how long it takes between PreThink and PostThink in each module, assuming that each forward is executed in the same order each time. This would include how long it takes to look up the PostThink function. The profiler, however, isn't capable of checking times between functions and can only track how long it takes for a function to run to completion.

Basically, I think we'd need a developer to tell us. There's no real way of benchmarking them against each other properly.
So you are talking about the time that it takes since the module searches for the hooks that it have to call and the actual call.
I guess that that time is outside of the scope of the profile because what the profile measures is the time that our hook takes to happen.

It measures in the scope of our plugin, not in the module's. And, the call to the hook is made from the module, not from the plugin.
__________________

Last edited by joaquimandrade; 03-30-2009 at 11:09.
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-30-2009 , 11:09   Re: [TUT] Modules and efficient scripting
Reply With Quote #42

Actually, after thinking about it, I realized that it probably does a lookup on the creation of the client_PreThink forward for each instance of it in each plugin, then stores them once it's done. The "one forward" equivalent that FakeMeta uses probably acts similarly, but the difference is that it would have to execute each forward individually.

Since Engine probably does not create and destroy the forward each time it gets called, it would likely keep this lookup table throughout the time that AMXX stays loaded in the same state.

Basically, the difference would be almost negligible, but I would assume that multi forwards would be very slightly faster once one or more plugin is using them. If there are no plugins using a multi forward, it would probably be more expensive than no plugins using a FakeMeta one forward.

Quote:
Originally Posted by joaquimandrade View Post
So you are talking about the time that it takes since the module searches for the hooks that it have to call and the actual call.
I guess that that time is outside of the scope of the profile because what the profile measures is the time that our hook takes to happen.

It measures in the scope of our plugin, not in the module's. And, the call to the hook is made from the module, not from the plugin.
Yes, I noted that before. You can't really benchmark the lookup or module side.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-30-2009 , 11:12   Re: [TUT] Modules and efficient scripting
Reply With Quote #43

Quote:
Originally Posted by Hawk552 View Post
Actually, after thinking about it, I realized that it probably does a lookup on the creation of the client_PreThink forward for each instance of it in each plugin, then stores them once it's done. The "one forward" equivalent that FakeMeta uses probably acts similarly, but the difference is that it would have to execute each forward individually.

Since Engine probably does not create and destroy the forward each time it gets called, it would likely keep this lookup table throughout the time that AMXX stays loaded in the same state.

Basically, the difference would be almost negligible, but I would assume that multi forwards would be very slightly faster once one or more plugin is using them. If there are no plugins using a multi forward, it would probably be more expensive than no plugins using a FakeMeta one forward.



Yes, I noted that before. You can't really benchmark the lookup or module side.
Can you talk to a developer to tell us he's final opinion on that matter?
__________________
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-30-2009 , 11:32   Re: [TUT] Modules and efficient scripting
Reply With Quote #44

Quote:
Originally Posted by joaquimandrade View Post
Can you talk to a developer to tell us he's final opinion on that matter?
Well, we can wait for someone to come along.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-30-2009 , 11:44   Re: [TUT] Modules and efficient scripting
Reply With Quote #45

Quote:
Originally Posted by Hawk552 View Post
Well, we can wait for someone to come along.
Anyway, the point of all this story is that the true is fair from "Porting everything to fakemeta is optimizing".
__________________
joaquimandrade is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-30-2009 , 15:18   Re: [TUT] Modules and efficient scripting
Reply With Quote #46

Heh, someone want to edit this?

Quote:
Originally Posted by Silencer123
[IMG]http://img99.**************/img99/8696/fmg3eb1iw5.gif[/IMG]
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 03-30-2009 , 18:09   Re: [TUT] Modules and efficient scripting
Reply With Quote #47

Quote:
Originally Posted by Hawk552 View Post
Heh, someone want to edit this?

paint ftw!
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 03-30-2009 , 18:10   Re: [TUT] Modules and efficient scripting
Reply With Quote #48

Quote:
Originally Posted by SchlumPF* View Post

paint ftw!
True true.
Engine:
Fakemeta:
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 03-30-2009 , 19:19   Re: [TUT] Modules and efficient scripting
Reply With Quote #49

Quote:
Originally Posted by ot_207 View Post
True true.
Engine:
Fakemeta:
You are beginning to miss the point and just go in a total opposite direction which is bad in itself, this is not an anti-fakemeta crusade.
Fakemeta is fine to use it's not a no no and in fact you can do things with it that you are not able to with engine.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-30-2009 , 19:29   Re: [TUT] Modules and efficient scripting
Reply With Quote #50

Indeed. We should use forward/natives provided intelligently depending the need and whatever the module.
Arkshine is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode