FS#37006 - [python2] horrible performance
Attached to Project:
Arch Linux
Opened by Carlos (memeplex) - Saturday, 21 September 2013, 07:17 GMT
Last edited by Jan de Groot (JGC) - Friday, 06 December 2013, 08:10 GMT
Opened by Carlos (memeplex) - Saturday, 21 September 2013, 07:17 GMT
Last edited by Jan de Groot (JGC) - Friday, 06 December 2013, 08:10 GMT
|
Details
Comparison against a custom, built from sources with default
options, python:
Custom: Python 2.7.5 (default, Sep 21 2013, 03:54:47) [GCC 4.8.1 20130725 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> t=time.time(); import numpy; print time.time()-t 1.06899690628 >>> t=time.time(); import pandas; print time.time()-t 1.86351799965 Arch: Python 2.7.5 (default, Sep 6 2013, 09:59:46) [GCC 4.8.1 20130725 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> t=time.time(); import numpy; print time.time()-t 1.51807308197 >>> t=time.time(); import pandas; print time.time()-t 2.81632208824 Both suck, I agree, but the first sucks less. The numbers are more or less consistent across different runs. The site-packages are the same for both versions (the ones provided by arch in /usr/lib/python2.7/site-packages. |
This task depends upon
import numpy.ma # from /usr/lib/python2.7/site-packages/numpy/ma/__init__.py
# can't create /usr/lib/python2.7/site-packages/numpy/ma/__init__.pyc
# /usr/lib/python2.7/site-packages/numpy/ma/core.pyc has bad mtime
import numpy.ma.core # from /usr/lib/python2.7/site-packages/numpy/ma/core.py
# can't create /usr/lib/python2.7/site-packages/numpy/ma/core.pyc
# /usr/lib/python2.7/site-packages/numpy/ma/extras.pyc has bad mtime
import numpy.ma.extras # from /usr/lib/python2.7/site-packages/numpy/ma/extras.py
# can't create /usr/lib/python2.7/site-packages/numpy/ma/extras.pyc
You see the pattern, lots of "can't create *.pyc".
Then you run as root, bytecode compilation gets done and import is in much better shape:
Python 2.7.5 (default, Sep 6 2013, 09:59:46)
[GCC 4.8.1 20130725 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> t=time.time(); import numpy; print time.time()-t
0.371647834778
>>>
cd /usr/lib/python2.7/site-packages && { python -m compileall . ; python -O -m compileall . ; }
It seems to be common to create both .pyc and .pyo files.
http://www.debian.org/doc/packaging-manuals/python-policy/ch-module_packages.html (section 2.6)
http://fedoraproject.org/wiki/Packaging:Python#Byte_compiling
sudo pacman -Sy python2
python2 -v -c 'import numpy' # not as root!
/usr/lib/python2.7/os.py: 1378454192
/usr/lib/python2.7/os.pyc: 1378454179
/usr/lib/python2.7/os.pyo: 1378454185
os.py is newer than both pyc and pyo, that's how it triggered python's recompile mechanism.
This also applies for the 'python2' package itself, as it did the same thing in PKGBUILD:
# clean up #!s
find "${pkgdir}"/usr/lib/python${_pybasever}/ -name '*.py' | \
xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python2|"