Re: Bug in log.c

Andreas Fink <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
On Jeudi, juin 19, 2003, at 06:03  Uhr, Stipe Tolj wrote:

> Nisan Bloch schrieb:
>>
>> Hi
>>
>> We run into this all the time with out SMPP server. Threads are 
>> spawned for
>> new ESME connections and terminated on disconnect. Some of our users
>> connect and disconnect very regularily and the thread-id often goes 
>> over
>> 1024. This however means quite a few changes to the way the log stuff
>> currently works. We may have to use a list instead of an array.
>
> hmmm, list are *slow* compared to a fixed array.
>
> You have to keep in mind that the logging functions are caller
> *really* a lot of times anywhere in the code, so the mapping has to be
> as fast as possible.


there's an easier way.

you make two array. one with the tread ID and one with the logfile 
stuff.
the code has to go through array1 to find the correct thread ID to then 
find the thing it needs in array2.
Worst case scenario: a loop from 1-1024 in a sequencial array of 
integers. Every CPU can do that blasting fast and cache helps.

improvement could be done with hashing function.  or by using 
thread%1024 as a default place and if its not there go searching...


Andreas Fink
Global Networks Switzerland AG

------------------------------------------------------------------
Tel: +41-61-6666333  Fax: +41-61-6666334   Mobile: +41-79-2457333
Global Networks, Inc. Clarastrasse 3, 4058 Basel, Switzerland
Web: http://www.global-networks.ch/      [email protected]
------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.