Raised This Month: $51 Target: $400
 12% 

Efficient caching method


Post New Thread Reply   
 
Thread Tools Display Modes
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-24-2016 , 10:46   Re: Efficient caching method
Reply With Quote #11

Hence why I said a cached value. The size is cached, it isn't calculated each call.
klippy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-24-2016 , 12:39   Re: Efficient caching method
Reply With Quote #12

Quote:
Originally Posted by Potato Uno View Post
Doing ++ in pawn is way worse than doing ++ in C++, because every operation on pawn is a bytecode dispatch on the JIT (push parameters to stack, run assembly on the CPU, send results back to pawn... and that's an oversimplification). Anything you do in pawn will be way slower than equivalent code in C++.
This isn't remotely correct, the JIT compiles native code per-function - stuff like math operations compile to identical assembly ops as C++.

EDIT: And the GetArraySize native is just a Handle unwrap and a member variable read.
__________________

Last edited by asherkin; 07-24-2016 at 12:42.
asherkin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-24-2016 , 19:23   Re: Efficient caching method
Reply With Quote #13

All I know.

With Dynamic when I first implemented member offsets. Getting a member by offset was slower than getting member by name.

After some profiling I noticed GetArraySize was spending the most time in Get*ByOffset.

I replaced GetArraySize with internal counts and walah, Get*ByOffset was faster than Get*.
__________________
Neuro Toxin is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-24-2016 , 19:31   Re: Efficient caching method
Reply With Quote #14

Most of GetArraySize()'s overhead comes from SM's handle reading logic.
__________________
WildCard65 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 07-25-2016 , 00:52   Re: Efficient caching method
Reply With Quote #15

It is more likely there was a mistake in your code or simply that the change meant you made fewer native calls in that particular path. The get size native itself is going to be the fastest of the ADT array natives.
Fyren is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-25-2016 , 02:03   Re: Efficient caching method
Reply With Quote #16

I checked my changes, I only removed GetArraySize(), I didn't replace the check with any counter logic.

Fyren, can you teach me your secrets to time travel please?

I would like to be a member since 2666 please!
__________________
Neuro Toxin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-25-2016 , 02:46   Re: Efficient caching method
Reply With Quote #17

Quote:
Originally Posted by Neuro Toxin View Post
Fyren, can you teach me your secrets to time travel please?

I would like to be a member since 2666 please!
Psst, I know the secret to time travel. It looks something like this:

Code:
UPDATE members SET join_date='2106-02-01 00:00:00';
I can't be arsed to look up the VBulletin table structure to see if that's right.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-25-2016 , 02:56   Re: Efficient caching method
Reply With Quote #18

Lol Timelord.

Edit: Dont forget the WHERE clause
__________________

Last edited by Neuro Toxin; 07-25-2016 at 02:58.
Neuro Toxin is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 07-25-2016 , 10:29   Re: Efficient caching method
Reply With Quote #19

Quote:
Originally Posted by Neuro Toxin View Post
I checked my changes, I only removed GetArraySize(), I didn't replace the check with any counter logic.
There's still a cost, even if the cost of getting an ADT array's size is lower than the other natives. There's added overhead when calling SP to C++ compared to SP to SP (or C++ to C++).

Quote:
Originally Posted by Powerlord View Post
Psst, I know the secret to time travel. It looks something like this:

Code:
UPDATE members SET join_date='2106-02-01 00:00:00';
I can't be arsed to look up the VBulletin table structure to see if that's right.
Or just use the admin control panel.
Fyren is offline
Reply



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 02:59.


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