Hi Arno,

On Tue, Dec 7, 2010 at 12:42 PM, Arno Garrels <arno.garr...@gmx.de> wrote:

> Fastream Technologies wrote:
> > Hello,
> >
> > I have seen a bottleneck in ICS with tens of thousands of clients:
> > When a client is disconnected the TWSocketServer calls
> > FClientList->IndexOf() for finding the index to remove the object!
> > IndexOf is simply exhaustive search and it is a huge CPU hog when
> > there are 30k clients!
> >
> > In some other parts of our code we wrote we overcome this issue by
> > using a sorted TStringList holding the pointers normally held in
> > FClientList->Items[] in stringList->Objects[] and converting the
> > memory address to first integer and then String and assigning it to
> > the stringList->Strings[] (with the same index of course).
> >
> > Then we use a binary search function to search among the Strings[] to
> > find the index and delete without IndexOf. It works perfectly!
>
> Beside the fact that this has nothing to do with the subject
> "asynchronous sockets on Linux" your design is likely slower
> than current implementation. Though your binary search will be
> faster, inserts into a sorted list take much longer, you have to
> sum both, have you?
>
> --
> Arno Garrels
>
>
>
As far as I know, the TStringList->AddObject() method uses binary search for
finding the correct index to insert when TStringList->Sorted = true. I don't
know why I thought so but there is the method,

*Insert* method
Inserts a string at the given index position. Position 0 will force an
insert at the start.

So even if it is not like that, we can easily modify our binary search
function to find the index to insert first. But I don't think it would mean
much rational if the original class does not do it already when there is
they already have the property Sorted!

Regards,

SZ
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to