[Asterisk-Dev] Profiling results: Asterisk processing 5000 concurrent IAX registrations

Kevin P. Fleming kpfleming at digium.com
Mon Oct 31 07:46:36 MST 2005


Steve Kann wrote:

> Would it make a big difference to just use strcmp instead of strcasecmp? 
> My guess is that it would improve things by at most 25% or so, but 
> probably less (like 10%).  That's just my gut, though..

Yes, using strcmp() makes a noticeable difference. Another (additional) 
technique that I've tried is to use an 'int *' comparison when the 
string-to-be-searched-for is at least 3 characters long, to weed out the 
peers whose names don't have the same first four bytes... this makes a 
large difference as well.


> Obviously, you need to move from a linear search over all the peers 
> O(n), which is does n times (so the whole registration system is 
> O(n^2)), to some kind of indexed search..

The most efficient technique, unless you are using a small number of 
extremely short peer names, is to use string hashes and hash table 
lookups. I had much of that working a few months ago (before I came to 
Digium), and I'll be resurrecting that code about five minutes after 1.2 
is released :-)



More information about the asterisk-dev mailing list