sos icon indicating copy to clipboard operation
sos copied to clipboard

Testing SoS with PyPy

Open BoPeng opened this issue 6 years ago • 5 comments

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).

BoPeng avatar Mar 02 '19 18:03 BoPeng

It sounds promising! any short-term plans in trying it out?

gaow avatar Mar 08 '19 23:03 gaow

I had a second look at pypy since it now has beta-level support for Python 3.6.

  1. download pypy3 for mac
  2. Create a virtual env. I used pipenv
  3. Install pip with command bin/pypy3 -m ensurepip, which adds bin/pip3
  4. 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.

BoPeng avatar Apr 08 '19 18:04 BoPeng

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

BoPeng avatar Apr 08 '19 20:04 BoPeng

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.

BoPeng avatar Apr 08 '19 20:04 BoPeng

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.

BoPeng avatar Apr 09 '19 16:04 BoPeng