Ultimately the question of block size depends on platform as well as
network interconnect. I've seen really funny things happen on
wireless (I had a macbook pro for a while that couldn't break
100kbytes/second over WPA2 wireless), and have seen performance peak
across a gbit lan using anywhere from 4k to 32k block sizes depending
on the host and client configurations.
Generally, it's hard to go too wrong with 4k block sizes, from both a
performance and overhead perspective. It's significantly faster than
512 bytes (as was the default with asyncore/asynchat in Python 2.5),
and in testing that I have done (typically windows <-> windows on
10mbit, 100mbit, and 1gbit links) is within 10-20% of whatever block
size was the peak. Sure, you can take 8 more passes with 4k than 32k,
but if you really feel like going crazy, tossing in a loop like the
following might give a transfer rate increase...
...
first = 1
while first or sent == len(block):
first = 0
block = self.outq.popleft()
sent = self.send(block)
# handle cleanup
...
- Josiah