[Spice-devel] Is Python faster than C ?
Frediano Ziglio
fziglio at redhat.com
Fri Feb 3 15:58:23 UTC 2017
Hi,
obviously the subject is a bit provocative.
Recently I was working on the websocket branch with the help
of Jeremy. Target put it in a right shape.
Too many patches from me fixing issues, not much tested beside
spice-html and some integration stuff.
Luckily there is a semi official test suite for WebSockets
implementations called Autobahn test suite.
After fixing some problems I enabled the performance tests.
At the beginning the performances were terrible but mostly the
reason was the missing TCP_NODELAY settings.
After setting TCP_NODELAY performance are much better but still
some tests are worst than Python implementation!
So why Python is sometimes better than C ?
In this case the reply can be seen either using a network
capture or an strace. Basically the problem is that header and
packet are sent with 2 separate system call causing to send
2 packets instead of one (in many cases).
So back to initial question: Is Python faster than C ?
Well... the language don't guarantee the result if the
implementation is doing the wrong (or in this case the
not optimal) thing.
What does Python better than C in this case? I would probably
say buffering.
Back to us I'll use more writev, some buffering or some other
way to improve the network performance with websockets (if
it's really important).
Back to the current Spice code... is Spice doing the right
thing with buffering, network and such ?
I know the code is not optimal in that area but I did a small test
to check a possible sub-optimization using TLS sockets.
Using a modified (patch sent today) replay I counted the packets
either using not plain sockets and encrypted socket.
The difference is about 41% ! I would say there's surely space for
improves (it's true you have to account for more data due to TLS
framing but really 41% is quite a lot).
Frediano
More information about the Spice-devel
mailing list