Re: [gnet] gnet is slooow in receiving data
- From: Tim Muller <tpm101 gmx net>
- To: Ron Arts <raarts netland nl>, gnet gnetlibrary org
- Subject: Re: [gnet] gnet is slooow in receiving data
- Date: Thu, 14 Nov 2002 14:07:43 +0000
On Thursday 14 November 2002 12:53, Ron Arts wrote:
> I've written a simple multithreaded server application for inhouse use.
> This server accepts connections, asks for user and password a la
> the POP-3 protocol, and accepts an XML data file for upload.
> gnet_conn_readline (conn, NULL, 1024, 30000);
> case GNET_CONN_STATUS_READ:
> readline, save to file....
> Everything works fine, but performance is really terrible, even a
> 256KB file takes a full minute, while CPU load goes to 100%.
> If I connect an strace to the server I see:
> read(7, "t", 1) = 1
> which means the input is read byte-for-byte from the network.
> Is this normal behaviour?
I think the problem might be that you are using gnet_conn_readline().
I would use gnet_conn_readany() with a buffer (not too small!).
The drawback is that you have to assemble the pieces you get yourself and
check for the end-of-line character yourself, but it should be a lot faster.
I've done it this way in some apps of mine, and I haven't noticed any
performance problems yet.
Disclaimer: I'm not a gnet hacker, I might be totally wrong ;-)
Hope this helps.
] [Thread Prev