strange sockets

Jim Segrave jes at nl.demon.net
Fri Nov 4 12:15:22 EST 2005


In article <dkfqhb$l1l$1 at opal.futuro.pl>, Skink  <spam at me.please> wrote:
>Hi,
>
>I'm preparing a python server that sends java classes and resources to
>custom java class loader. In order to make it faster I don't want to use
>URLClassLoader that uses HTTP protocol 1.0 and for each class/resource
>creates own connection.
>Instead I'd like to use raw sockets with simple protocol:
>
> - class loader sends a line terminated with \n with resource to get
> - python server reads that line, gets the file and sends back an
>integer with file length and then the file itself
> - class loader reads a lenght integer and then reads the remainig data
>
>
>The problem is when I try to read several files the first one is read
>quite fast, but the rest is read 40 x slower. For example (time is in
>seconds):
>
>% python client.py client.py client.py client.py server.py server.py
>init 0.00066089630127
>client.py 0.000954866409302
>client.py 0.0408389568329
>client.py 0.0409188270569
>server.py 0.0409059524536
>server.py 0.0409259796143
>
>what's wrong here?

At a guess, what you've measured is how long it takes to transfer the
data to the underlying OS socket buffers. The first transfer fills the
buffers, subsequent ones have to wait until the data has been put on
the wire and acknowledged before there's space for the writes. 

-- 
Jim Segrave           (jes at jes-2.demon.nl)




More information about the Python-list mailing list