Re: [twsocket] Socket throughput optimizations

2008-06-23 Thread Tobias Rapp
Olivier Sannier wrote:
>> Here are a few ideas to get high performances:
>> 4) Enlarge winsock buffers
>> 5) Enlarge TWSocket send buffer (BufSize property) to mach actual network 
>> packet size. By default BufSize is the size of a standard ethernet packet.
>>   
> What values would you recommend for a 802.11 100Mbps network?

In my testings I had good results when enlarging the winsock buffers to 
256kB. I use this relatively large buffer size as my application has a 
rather limited amount of clients (approx. 10-20) and is running in a 
network with high round-trip-times (approx. 8ms).

Regards,
Tobias

-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-20 Thread Arno Garrels
Olivier Sannier wrote:
> Francois PIETTE wrote:
>> Here are a few ideas to get high performances:
>> 4) Enlarge winsock buffers
>> 5) Enlarge TWSocket send buffer (BufSize property) to mach actual
>> network packet size. By default BufSize is the size of a standard
>> ethernet packet. 
>> 
> What values would you recommend for a 802.11 100Mbps network?

I do not know what Francois recommends, however I won't touch the 
default values in those networks, see my previous message in this
thread.

> 
>> 6) Avoid dynamic memory allocation as much as possible, including
>> long strings and dynamic arrays.
>> 
> Why is that?

Memory allocation takes some time, reallocations (upon buffer grow) will
also move data around in memory, all this should be avoided as much as
posible.  

--
Arno Garrels
-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-19 Thread Francois PIETTE
>> Here are a few ideas to get high performances:
>> 4) Enlarge winsock buffers
>> 5) Enlarge TWSocket send buffer (BufSize property) to mach actual network
>> packet size. By default BufSize is the size of a standard ethernet 
>> packet.
>>
> What values would you recommend for a 802.11 100Mbps network?

At first glance, a multiple of the physical packet size (MTU).

>> 6) Avoid dynamic memory allocation as much as possible, including long
>> strings and dynamic arrays.
>>
> Why is that?

Memory allocation is a [relatively] slow process and tend to fragment memory 
which makes it even slower. Using FastMM enhance the behaviour but it is 
still there.

Long strings and dynamic array are just dynamic memory allocation whitout 
naming it.

Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-19 Thread Olivier Sannier
Francois PIETTE wrote:
> Here are a few ideas to get high performances:
> 4) Enlarge winsock buffers
> 5) Enlarge TWSocket send buffer (BufSize property) to mach actual network 
> packet size. By default BufSize is the size of a standard ethernet packet.
>   
What values would you recommend for a 802.11 100Mbps network?

> 6) Avoid dynamic memory allocation as much as possible, including long 
> strings and dynamic arrays.
>   
Why is that?

Thanks for your answers.
-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-11 Thread Arno Garrels
Hello Tobias,
> 
> Yes, I've tried that and got 12MB/s for standard Windows file copy
> (CIFS), 4MB/s for FTP file copy using Internet Explorer and 3MB/s for
> FTP file copy using the ICS demo client.

Strange, I can upload a big file at around 5,5 MB/sec using TFTPCli in
a 100 MBit/s LAN, I think it could be even faster since the write cache
is disabled on the server HDDs.
 
> I have also tested these client using different round-trip-times (I
> have 
> a GNU/Linux router in between in my test setup where I can adjust RTT)
> and realized that they degrade quite different when increasing the RTT
> (2ms, 4ms) so I asked myself how to handle this.

Why do you want to increase the RTT when speed is what you are 
interested in? 
 
>> You may also write two very simple client and server applications.
>> The client sending 256KB of data comming from memory (to avoid disk
>> I/O slowness) and the server just reading the data and throwing it
>> away (do not write to disk or allocate memory to store data). You'll
>> have an idea abour the maximum thruput you can have.

I just did a quick test with such a simple ICS client and server to 
achieve high transfer rates (all with default settings and a $ bytes,
custom send/receive buffer allocated once at application start). 
In a 100 MBit/s LAN I was able to send around 98 MBit/s, the average 
RTT was 0.7 ms (Wireshark). But I wonder why a single call to Receive()
returns far more bytes than the per-socket kernel buffer space
reserved for receives (I got up to $ bytes in a single call)?
Looks like winsock.dll buffers incomming data as well.
   
--
Arno Garrels   

-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-11 Thread Wilfried Mestdagh
Hello Tobias,

> In order to messure transmission speed I would write a small
> test suite including client and server. The client would send
> preallocated, constant data blocks in a loop and would use event
> OnDataSent to send the next block. The server would simply through
> away anything. 

You find something like this on my site.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-11 Thread Tobias Rapp
Hello Francois,

thanks for your long and descriptive reply.

> Using the same client or server, at the same time in the day, are you able 
> to check for network thruput using other tools ? [...]

Yes, I've tried that and got 12MB/s for standard Windows file copy 
(CIFS), 4MB/s for FTP file copy using Internet Explorer and 3MB/s for 
FTP file copy using the ICS demo client.

I have also tested these client using different round-trip-times (I have 
a GNU/Linux router in between in my test setup where I can adjust RTT) 
and realized that they degrade quite different when increasing the RTT 
(2ms, 4ms) so I asked myself how to handle this.

> You may also write two very simple client and server applications. The 
> client sending 256KB of data comming from memory (to avoid disk I/O 
> slowness) and the server just reading the data and throwing it away (do not 
> write to disk or allocate memory to store data). You'll have an idea abour 
> the maximum thruput you can have.

The max throughput I got on my 1Gbps network was by using the ICS FTP 
demo and changing the tWSocket.BufSize to 256kB and using 
WSocket_setsockopt(FHSocket, SOL_SOCKET, SO_SNDBUF, 256kB). This gives a 
throughput of 35MB/s (the FTP server is FileZilla running on Windows 
2003 server).

Using some very simple ICS-based client and server applications I get 
around 20MB/s when setting the client to the same buffer sizes. Don't 
know what to optimize on server side...

Anyway will try to follow the list of your suggestions, especially the 
one about separating the disk-writing by putting it into a separate thread.

Regards,
Tobias

-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-10 Thread Francois PIETTE
>> Which protocol ?
>
> Well, I'm basically using TCP. My client inherits from tWSocket and uses
> it's own XML-based protocol to deliver data blocks of around 256kB to
> the server (which is also a self-written Delphi ICS application).
>
> When connecting to the server app over a 1Gbps network cable with 2ms
> RTT I get only around 3-5MB/s. Processing each data block takes <5ms and
> I expected to gain at least 20MB/s of throughput.

Using the same client or server, at the same time in the day, are you able 
to check for network thruput using other tools ? For example, send a 500MB 
file from client to server using windows file copy or FTP and measure what 
it the thruput. You'll have an idea of the basic network thruput. Many 1Gbps 
networks actually doesn't work at that speed at all.

You may also write two very simple client and server applications. The 
client sending 256KB of data comming from memory (to avoid disk I/O 
slowness) and the server just reading the data and throwing it away (do not 
write to disk or allocate memory to store data). You'll have an idea abour 
the maximum thruput you can have.

Here are a few ideas to get high performances:
1) Use a separate thread to run your sockets
2) Do not write to the screen or to files synchronously: use a memory queue 
and have a separate thread empty the queue either for display (main thread) 
or to disk or DB.
3) If your hardware enables it, use jumbo frames at both client and server 
side
4) Enlarge winsock buffers
5) Enlarge TWSocket send buffer (BufSize property) to mach actual network 
packet size. By default BufSize is the size of a standard ethernet packet.
6) Avoid dynamic memory allocation as much as possible, including long 
strings and dynamic arrays.
7) Call TWSocket.Send and TWSocket.Receive with the largest possible buffer.
8) Make sure you are not disk I/O bound : if your data comes from disk or go 
to disk, it may happend that your are limited by disk thruptu which maybe 
quite slower than 1Gbps once the cache has been overflown.
9) Make sure your CPU is fast enough. Usually you need qui CPU power to 
process data at a sustained rate of 1Gbps.
10) Avoid anything blocking, allow the message pump to run as fast as 
possible, at least in the thread handling your sockets
11) Use multithreading with a multicore CPU: separate actual network I/O and 
data processing. Design your code to avoid Synchronize as much as possible. 
Avoid critical sections number and range as much as possible (this will 
maximize parallelism).
12)


--
[EMAIL PROTECTED]
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-10 Thread Arno Garrels
Hi Tobias,

In order to messure transmission speed I would write a small
test suite including client and server. The client would send
preallocated, constant data blocks in a loop and would use event
OnDataSent to send the next block. The server would simply through
away anything. 

--
Arno Garrels


> Francois Piette wrote:
>> Which protocol ?
> 
> Well, I'm basically using TCP. My client inherits from tWSocket and
> uses it's own XML-based protocol to deliver data blocks of around
> 256kB to the server (which is also a self-written Delphi ICS
> application). 
> 
> When connecting to the server app over a 1Gbps network cable with 2ms
> RTT I get only around 3-5MB/s. Processing each data block takes <5ms
> and I expected to gain at least 20MB/s of throughput.
> 
> /Tobias
-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-10 Thread Tobias Rapp
Francois Piette wrote:
> Which protocol ?

Well, I'm basically using TCP. My client inherits from tWSocket and uses 
it's own XML-based protocol to deliver data blocks of around 256kB to 
the server (which is also a self-written Delphi ICS application).

When connecting to the server app over a 1Gbps network cable with 2ms 
RTT I get only around 3-5MB/s. Processing each data block takes <5ms and 
I expected to gain at least 20MB/s of throughput.

/Tobias


-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-10 Thread Francois Piette
Which protocol ?
--
[EMAIL PROTECTED]
http://www.overbyte.be

- Original Message - 
From: "Tobias Rapp" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Tuesday, June 10, 2008 10:02 AM
Subject: [twsocket] Socket throughput optimizations


> Hi!
> 
> I'd like to know if anybody of you has some suggestions about how to 
> tune a tWSocket-based application for data throughput.
> 
> Do you change some socket buffer sizes? Like in
> 
> WSocket_setsockopt(FHSocket, SOL_SOCKET, SO_SNDBUF, ...);
> WSocket_setsockopt(FHSocket, SOL_SOCKET, SO_RCVBUF, ...);
> 
> What else do you suggest? Maybe using a second internal buffer so one 
> writes the retrieved data in OnDataAvailable into that buffer and 
> returns immediately? Using multiple threads?
> 
> Other ideas?
> 
> /Tobias
> -- 
> 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
-- 
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


Re: [twsocket] Socket throughput optimizations

2008-06-10 Thread Fastream Technologies
What is the speed you want to achieve? Did you try running in a worker
thread? Here we have speeds of up to 2Gbps from local-to-local!

Regards,

SZ

On Tue, Jun 10, 2008 at 11:02 AM, Tobias Rapp <[EMAIL PROTECTED]> wrote:

> Hi!
>
> I'd like to know if anybody of you has some suggestions about how to
> tune a tWSocket-based application for data throughput.
>
> Do you change some socket buffer sizes? Like in
>
> WSocket_setsockopt(FHSocket, SOL_SOCKET, SO_SNDBUF, ...);
> WSocket_setsockopt(FHSocket, SOL_SOCKET, SO_RCVBUF, ...);
>
> What else do you suggest? Maybe using a second internal buffer so one
> writes the retrieved data in OnDataAvailable into that buffer and
> returns immediately? Using multiple threads?
>
> Other ideas?
>
> /Tobias
> --
> 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
>
-- 
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