Hi Richard,

definitely there is a difference , but never tried to quantify it - of 
course, we can make a simple script to loop 100000 times and search for 
an AVP in a list of 100 AVPs.
But as searching for an AVP is pure CPU, the question is how relevant is 
this difference relative to a DB query duration or DNS lookup ;)

Regards,
Bogdan

Richard Revels wrote:
> Good to remember.  Thank you.  I normally spend tons of time thinking about 
> how and why I'm accessing the database and file system and no time thinking 
> about how I'm manipulating variables in script.  
>
> While we are on this subject, I've always wondered about something, but not 
> enough to test it out.  I had to modify the snippet below quite a bit before 
> sending it due to the fact that I use m4 and let it convert strings to 
> integer named avp's.  One of the primary reasons I started using m4 was the 
> warning in the docs about the speed difference of manipulating avp's with 
> string names vs avp's with integer names and how using aliases on the avp's 
> was a better idea.  Do you know if any comparisons were ever done to quantify 
> that difference?  I'm wondering if the difference between reading, then 
> modifying 1000 avp's using string vs integer would be like 10 milliseconds vs 
> 1 second or 10 milliseconds vs 100 milliseconds.
>
> Like I say, this was never a big enough concern to make me test it out but if 
> you know then I would like to know.  : >
>
> Richard
>  
> On Mar 4, 2010, at 6:45 AM, Bogdan-Andrei Iancu wrote:
>
>   
>> Hi Richard,
>>
>> 1 important comment here - the global vars are something more powerful 
>> than statistic vars. And of course, they come with more penalties. 
>> Operating with the global vars requires internal locking (over the 
>> variable) - this may lead to a general slowdown of opensips as all the 
>> procs will keep syncronizing over the lock for the this vars. The stat 
>> vars are using atomic ops (internally) and they do not require locking.
>>
>> just my 2 cents on this,
>> Bogdan
>>
>> Richard Revels wrote:
>>     
>>> Most likely this is where Bogdan is headed but, if you only want to 
>>> increment and reset some variables in the script there are global vars 
>>> available to do that with.  cfgutils module.
>>>
>>> #first a var that is shared across all processes
>>> modparam("cfgutils", "shvset", "didtracker=i:0")
>>>
>>> #now one that will be unique to each process thread
>>> modparam("cfgutils", "varset", "threadtracker=s:00000")
>>>
>>> Then in the script to, say, randomly select a from user:
>>>
>>>                $avp(s:newfromheader) = $hdr(From);
>>>                $avp(s:holder)=$shv(didtracker);
>>>                $shv(didtracker)=$shv(didtracker) + 1;
>>>                if( $shv(didtracker) == 50000 )
>>>                        $shv(didtracker)=0;
>>>                $avp(s:offset)= 5 - $(avp(s:holder){s.len});
>>>                
>>> $var(matchup)=$(var(threadtracker){s.substr,0,$avp(s:offset)}) + 
>>> $avp(s:holder);
>>>                if( dp_translate("42", "$var(matchup)/$var(matchup)") )
>>>                {
>>>                        $avp(s:newfromheader) = "sip:" + $var(matchup) + "@" 
>>> + $fd;  #this could change again for oli tag or something so
>>>                        setflag(FLAG_CHANGED_FROMHEADER);   #use flag to 
>>> insure we only change from header once in t_relay route              
>>>                }
>>>
>>>
>>> Richard
>>>
>>> On Mar 3, 2010, at 7:56 PM, Paweł Pierścionek wrote:
>>>
>>>
>>>       
>>>> On 2010-03-03, at 19:20, Bogdan-Andrei Iancu wrote:
>>>>
>>>>
>>>>         
>>>>> Hi Pawel,
>>>>>
>>>>> for read, the stats vars are available only via the MI interface (the 
>>>>> get_statistics function).
>>>>>
>>>>> do you want to read the stats from the statistics module only, or all of 
>>>>> them?
>>>>>
>>>>>           
>>>> Nah, only the ones defined in my script/statistics module and log/print 
>>>> them and reset them in a timer route.
>>>>
>>>>         


-- 
Bogdan-Andrei Iancu
www.voice-system.ro


_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to