[pypy-issue] Issue #2305: asyncio benchmarks from uvloop project slower on PyPy3 than on CPython (pypy/pypy)

squeaky issues-reply at bitbucket.org
Sun May 22 07:08:55 EDT 2016


New issue 2305: asyncio benchmarks from uvloop project slower on PyPy3 than on CPython
https://bitbucket.org/pypy/pypy/issues/2305/asyncio-benchmarks-from-uvloop-project

squeaky:

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
```





More information about the pypy-issue mailing list