Re: [twsocket] IndexOf is slow when there are thousands of clientsconnected

2010-12-07 Thread Fastream Technologies
So you are right in your saying that when Sorted = true, Add()'s are with binary search. But there is a HACK one needs to be very careful about: If you do not set Duplicates = dupAccept, then it calls IndexOf() before inserting to see if the same value exists!! That must have been the reason our c

Re: [twsocket] IndexOf is slow when there are thousands ofclientsconnected

2010-12-07 Thread Fastream Technologies
Hello Arno, On Tue, Dec 7, 2010 at 7:48 PM, Arno Garrels wrote: > Fastream Technologies wrote: > > Hello, > > > > I have fixed the function as below (providing for the sake of > > completeness): > > You are re-inventing the wheel. Simply set property TStringList.Sorted to > True > and a Add() or

Re: [twsocket] IndexOf is slow when there are thousands of clientsconnected

2010-12-07 Thread Arno Garrels
Anton S. wrote: > Arno wrote: >> I don't think so, why should it? > > Well, the connection to HTTP client is closed when response is sent That depends on whether the client uses HTTP 1.0 or HTTP 1.1 and whether or not the Keep-Alive header is sent. > (usually; there are some options in the requ

Re: [twsocket] IndexOf is slow when there are thousands ofclientsconnected

2010-12-07 Thread Arno Garrels
Fastream Technologies wrote: > Hello, > > I have fixed the function as below (providing for the sake of > completeness): You are re-inventing the wheel. Simply set property TStringList.Sorted to True and a Add() or AddObject() uses binary search to Insert data at the right index. As I mentioned

Re: [twsocket] IndexOf is slow when there are thousands of clients connected

2010-12-07 Thread Angus Robertson - Magenta Systems Ltd
> >clientString := IntToStr(ULong(Client)) > Won't it be much faster to use TList with custom Compare method > which would compare Client pointers as integers? String comparison > is a waste. Exactly, strings are totally unnecessary, ICS already uses sorted TLists in OverbyteIcsFtpSrvT for direc

Re: [twsocket] IndexOf is slow when there are thousands of clientsconnected

2010-12-07 Thread Fastream Technologies
Hello, I have fixed the function as below (providing for the sake of completeness): function seekIndexToInsertForSortedStringList(stringList: TStringList; stringToAdd: String; caseinsensitive: boolean) : Integer; var low, mid, high: integer; begin if(stringList.Count = 0) then begin

Re: [twsocket] IndexOf is slow when there are thousands of clients connected

2010-12-07 Thread Fastream Technologies
For this very particular FClientList, you are right. But for example we use the same function for RAMCacheFile and DISKCacheFile witht the URI in String and the object in the Object. So we needed this function anyway and just tested to use it for this purpose as well... Regards, SZ On Tue, Dec 7

Re: [twsocket] IndexOf is slow when there are thousands of clientsconnected

2010-12-07 Thread Anton S.
Arno wrote: >I don't think so, why should it? Well, the connection to HTTP client is closed when response is sent (usually; there are some options in the request header to keep it but these cases are rarer). I'm just supposing, not asserting. -- Anton -- To unsubscribe or change your settings

Re: [twsocket] IndexOf is slow when there are thousands of clients connected

2010-12-07 Thread Arno Garrels
Anton S. wrote: > Fastream Technologies wrote: >> clientString := IntToStr(ULong(Client)) > Won't it be much faster to use TList with custom Compare method which > would compare Client pointers as integers? String comparison is a > waste. That's the next point ;) See my test it uses a sorted TObje

Re: [twsocket] IndexOf is slow when there are thousands of clients connected

2010-12-07 Thread Anton S.
Fastream Technologies wrote: >clientString := IntToStr(ULong(Client)) Won't it be much faster to use TList with custom Compare method which would compare Client pointers as integers? String comparison is a waste. -- Anton -- To unsubscribe or change your settings for TWSocket mailing list please

Re: [twsocket] IndexOf is slow when there are thousands of clientsconnected

2010-12-07 Thread Arno Garrels
Anton S. wrote: > I dared to start the discussion in a separate thread. > >> 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 exhau

Re: [twsocket] IndexOf is slow when there are thousands of clientsconnected

2010-12-07 Thread Arno Garrels
Arno Garrels wrote: > Fastream Technologies wrote: >> 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, > > Yes, it actually uses function

Re: [twsocket] FYI: asynchronous sockets on Linux

2010-12-07 Thread Fastream Technologies
Hello Arno, On Tue, Dec 7, 2010 at 1:57 PM, Arno Garrels wrote: > Fastream Technologies wrote: > > 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 > >

[twsocket] IndexOf is slow when there are thousands of clients connected

2010-12-07 Thread Anton S.
I dared to start the discussion in a separate thread. >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 hug

Re: [twsocket] FYI: asynchronous sockets on Linux

2010-12-07 Thread Arno Garrels
Fastream Technologies wrote: > 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, Yes, it actually uses function QuickSort but that is still

Re: [twsocket] FYI: asynchronous sockets on Linux

2010-12-07 Thread Fastream Technologies
Hi Arno, On Tue, Dec 7, 2010 at 12:42 PM, Arno Garrels 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

Re: [twsocket] FYI: asynchronous sockets on Linux

2010-12-07 Thread Arno Garrels
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

[twsocket] Test case for thread-safe TSslContext FreeNotification and RemoveFreeNotification

2010-12-07 Thread Arno Garrels
Related to thread: "Strange ICS application issue (MadExcept report)" http://marc.info/?l=twsocket&m=129137495622903&w=2 {code} program SslContextFreeNotificationTest; { Test case thread-safe TSslContext.FreeNotification and TSslContext.RemoveFreeNotification. Requires at least ICSv7 SVN revi