[New-bugs-announce] [issue16787] asyncore.dispatcher_with_send - increase the send buffer size

Charles-François Natali report at bugs.python.org
Wed Dec 26 14:51:05 CET 2012


New submission from Charles-François Natali:

As noted in issue #12498, asyncore.dispatcher_with_send only sends 512 bytes at a time: this is 1/3 of the Ethernet MTU, which reduces greatly the attainable bandwidth and increases the CPU usage.
Here's a patch bumping it to 8192 (and making it a class member so that derived classes can customize it if needed, although not documented).

Here's the result of a simplistic benchmark using asyncore.dispatcher_with_send to send data to a server:
Without patch:
"""
$ time ./python ~/test_asyncore.py localhost 4242

real    0m6.098s
user    0m4.472s
sys     0m1.436s
"""

With patch:
"""
$ time ./python ~/test_asyncore.py localhost 4242

real    0m0.937s
user    0m0.796s
sys     0m0.112s
"""

Of course, this is using the loopback interface, but it shows that the performance gain can non negligible. The test script is attached (use "netcat -l -p 4242" as server).

----------
components: Library (Lib)
files: asyncore_buffsize.diff
keywords: easy, needs review, patch
messages: 178212
nosy: giampaolo.rodola, neologix, xdegaye
priority: normal
severity: normal
stage: patch review
status: open
title: asyncore.dispatcher_with_send - increase the send buffer size
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file28442/asyncore_buffsize.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16787>
_______________________________________


More information about the New-bugs-announce mailing list