[Python-Dev] Python 2.3b1 has 20% slower networking? (original) (raw)

Itamar Shtull-Trauring itamar@itamarst.org
Sun, 27 Apr 2003 14:53:16 -0400


The "we always wrap socket objects with python class" change seems to have slowed down networking on Linux (and presumably other platforms where socket objects used to be unwrapped.)

Moshe Zadka ran some benchmarks on Linux (2.4.9 - a redhat machine at work probably) with 2.2 and 2.3b1 using Demos/sockets/throughput.py.

For count of 1000: 2.3 server, 2.3 client: Throughput: 13556.811 K/sec. 2.3 server, 2.2 client: Throughput: 24917.862 K/sec. 2.2 server, 2.2 client: Throughput: 29838.491 K/sec.

10,000: 2.3 server, 2.3 client: Throughput: 35994.749 K/sec. 2.3 server, 2.2 client: Throughput: 34398.085 K/sec. 2.2 server, 2.2 client: Throughput: 49488.916 K/sec.

50,000: 2.3 server, 2.3 client: Throughput: 39002.538 K/sec. 2.3 server, 2.2 client: Throughput: 48064.785 K/sec. 2.2 server, 2.2 client: Throughput: 59799.672 K/sec.

On a 2.3a2 I have I did "socket.socket = socket._socketobject", and got a 20% slowdown compared to 2.2 on throughput. (2.3a2 without this change is the same speed as 2.2).

Can other people do some tests to verify these numbers?

If this slowdown is confirmed, it is really not acceptable, since the change seems to have been made only to support making timeout sockets slightly easier to use. Why should everyone have to pay a speed penalty just so a minority of people can skip calling a "socket.installtimeoutsupport()" at the beginning of their program? it's just one line of code they'd need to add.

In real programs the speed drop would probably be much less pronounced, although I bet this slows down e.g. Anthony Baxter's portforwarder quite a bit. If Python 2.3 is released without fixing this Twisted will probably monkeypatch the socket module so that we can get full performance, since we have our own (unavoidable) layers of Python indirection :)

-- Itamar Shtull-Trauring http://itamarst.org/ http://www.zoteca.com -- Python & Twisted consulting