1. Pypy
  2. Untitled project
  3. pypy
  4. Issues

Issues

Issue #2305 new

asyncio benchmarks from uvloop project slower on PyPy3 than on CPython

squeaky
created an issue

http://magic.io/blog/uvloop-blazing-fast-python-networking/

PyPy3 nightly server & client
-----------------------------

1KiB

pypy3 client.py --num 10000 --workers 10 --msize 1000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
100000 in 27.98492121696472
3573.352921907783 requests/sec

10KiB

pypy3 client.py --num 10000 --workers 10 --msize 10000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
100000 in 42.212645053863525
2368.9583979492295 requests/sec

100 KiB

pypy3 client.py --num 10000 --workers 10 --msize 100000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
100000 in 231.10237002372742
432.7086736052639 requests/sec


CPython 3.5 server & client
---------------------------

1KiB

/usr/bin/python3.5 client.py --num 10000 --workers 10 --msize 1000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
100000 in 24.576037406921387
4069.004223269812 requests/sec


10KiB

/usr/bin/python3.5 client.py --num 10000 --workers 10 --msize 10000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
100000 in 20.850675344467163
4796.007723871425 requests/sec


100KiB

/usr/bin/python3.5 client.py --num 10000 --workers 10 --msize 100000
will connect to: ('127.0.0.1', 25000)
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
Sending 10000 messages
100000 in 52.21383476257324
1915.2012192691843 requests/sec

Steps to reproduce:

I edited the benchmarks from https://github.com/MagicStack/uvloop/tree/master/examples/bench to not use async and await keywords

1. Get the latest nightly of pypy3
2. If you are running a system that is not exactly like Ubuntu 14.04 LTS 
  * `ldd bin/pypy3` to lookup broken symbols and libraries,
  * you can get openssl from http://packages.ubuntu.com/trusty/amd64/libssl1.0.0/download,
    unpack it and drop libssl.so.1.0.0 and libcrypto.so.1.0.0 into `bin` where `pypy3` binary resides 
  * everything else works with symlinking in your `/usr/lib64`
3. Get the develop branch of virtualenv https://github.com/pypa/virtualenv/archive/develop.zip and unzip it
4. Given your pypy3 tarball was unpacked to `pypy-c-jit-84568-d463dd98e6a6-linux64`:


LD_LIBRARY_PATH=pypy-c-jit-84568-d463dd98e6a6-linux64/bin virtualenv-develop/virtualenv.py -p pypy-c-jit-84568-d463dd98e6a6-linux64/bin/pypy3 venv-pypy3


5. Fix virtualenv by coping `libssl.so.1.0.0` and `libcrypto.so.1.0.0` into `venv-pypy3/bin`
   if you had problems with openssl
6. Activate virtualenv and `pip install asyncio`
6a. Fix missing `time.get_clock_info` in PyPy by hardcoding your monotonic clock resolution
    in `asyncio/base_events.py`, I got my resolution from CPython 3.5

Substitute

self._clock_resolution = time.get_clock_info('monotonic').resolution

with

self._clock_resolution = 1e-09


7. Run the attached server.py


python server.py --print


8. Run the client

python client.py --num 10000 --workers 5


9. Play with other options and see your results

Comments (4)

  1. Philip Jenvey

    get_clock_info is now supported (on posix) and the latest virtualenv 15.0.2 should work w/ pypy3

    I don't know if vmprof supports pypy3, its docs claim minimum of 3.4. If it does work a good next step would be running this benchmark under it

  2. Log in to comment