sos
sos copied to clipboard
Testing SoS with PyPy
PyPy finally has alpha-level support for Python 3.6, which means we can finally test it with SoS. It would be interesting to see if SoS can run on pypy3.6, and if so, if it really performs faster than CPython (quoting the on average 7.6 times faster statistics from their website).
It sounds promising! any short-term plans in trying it out?
I had a second look at pypy since it now has beta-level support for Python 3.6.
- download pypy3 for mac
- Create a virtual env. I used
pipenv - Install pip with command
bin/pypy3 -m ensurepip, which addsbin/pip3 - Run
bin/pip3 install sos, which ends with an error message
Command "/Users/bpeng1/Downloads/pypy3.6-v7.1.0-osx64/bin/pypy3
-u -c "import setuptools, tokenize;__file__='/private/var/folders/ys/gnzk0qbx5wbdgm531v82xxljv5yqy8/T/pip-build-7i9lraxl/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /var/folders/ys/gnzk0qbx5wbdgm531v82xxljv5yqy8/T/pip-fd2yi2w8-record/install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in /private/var/folders/ys/gnzk0qbx5wbdgm531v82xxljv5yqy8/T/pip-build-7i9lraxl/psutil/
So building psutil failed, although pypy says psutil is compatible.
The problem was caused by my own system and can be fixed by moving away /usr/local/include. After fixing the issue with psutil, the pypy version of SoS can be installed from pypi without problem.
Now, using a very simple test
input: for_each=dict(i=range(10000))
import time
time.sleep(0*i)
pypy beats cPython with 47s vs 31s, so there is indeed some performance benefit of using pypy.
(pypy3.6-v7.1.0-osx64) [bpeng1@bcbm-bpeng:~/Downloads/pypy3.6-v7.1.0-osx64]$ time sos run test
INFO: Running default:
INFO: Workflow default (ID=73f77713e6f9fd43) is executed successfully with 1 completed step and 10000 completed substeps.
real 0m47.304s
user 3m44.186s
sys 0m8.837s
(pypy3.6-v7.1.0-osx64) [bpeng1@bcbm-bpeng:~/Downloads/pypy3.6-v7.1.0-osx64]$ time bin/sos run test
INFO: Running default:
INFO: Workflow default (ID=73f77713e6f9fd43) is executed successfully with 1 completed step and 10000 completed substeps.
real 0m31.482s
user 2m15.755s
sys 0m10.329s
However, for whatever reason, sometimes the pypy version freezes after the workflow completes
$ time bin/sos run test -s force
INFO: Running default:
INFO: Workflow default (ID=333af83f177dde30) is executed successfully with 1 completed step and 1000 completed substeps.
The pypy version of SoS falls to an indefinite loop when running this example from #1213 . It is therefore necessary to test pypy after its gets out of beta.