New submission from Zhiming Wang <[email protected]>:
Python 2.7 could be significantly slower (5x in some cases) when compiled with
clang 3.x or 4.x, compared to clang 5.x. This is quite a problem on macOS,
since the latest clang from Apple (which comes with Xcode 9.2) is based on LLVM
4.x. This issue was first noticed by Bart Skowron and reported to the Homebrew
project.[1]
I ran some preliminary benchmarks (here[2] are the exact setup scripts) with
just a simple loop:
import time
def f(n):
while n > 0:
n -= 1
start = time.time()
f(50000000)
stop = time.time()
print('%.6f' % (stop - start))
and here are my results:
- macOS 10.13.2 on a MacBook Pro:
2.082144 /usr/bin/python2.7
7.964049 /usr/local/bin/python2.7
8.750652 dist/python27-apple-clang-900/bin/python2.7
8.476405 dist/python27-clang-3.9/bin/python2.7
8.625660 dist/python27-clang-4.0/bin/python2.7
1.760096 dist/python27-clang-5.0/bin/python2.7
3.254814 /usr/local/bin/python3.6
2.864716 dist/python-master-apple-clang-900/bin/python3
3.071757 dist/python-master-clang-3.9/bin/python3
2.925192 dist/python-master-clang-4.0/bin/python3
2.908782 dist/python-master-clang-5.0/bin/python3
- Ubuntu 17.10 in VirtualBox:
1.475095 /usr/bin/python2.7
8.576817 dist/python27-clang-3.9/bin/python2.7
8.165588 dist/python27-clang-4.0/bin/python2.7
1.779193 dist/python27-clang-5.0/bin/python2.7
1.728321 dist/python27-gcc-5/bin/python2.7
1.570040 dist/python27-gcc-6/bin/python2.7
1.604617 dist/python27-gcc-7/bin/python2.7
2.323037 /usr/bin/python3.6
2.964338 dist/python-master-clang-3.9/bin/python3
3.054277 dist/python-master-clang-4.0/bin/python3
2.734908 dist/python-master-clang-5.0/bin/python3
2.490278 dist/python-master-gcc-5/bin/python3
2.494691 dist/python-master-gcc-6/bin/python3
2.642277 dist/python-master-gcc-7/bin/python3
I haven't got time to run more rigorous benchmark suites (e.g., the
performance[3] package). I did try the floating point benchmark from
performance, and again saw a 2x difference in performance.
[1] https://github.com/Homebrew/homebrew-core/issues/22743
[2] https://gist.github.com/zmwangx/f8151ba8907ba8159a07fdd1528fc2b5
[3] https://pypi.python.org/pypi/performance
----------
messages: 310395
nosy: zmwangx
priority: normal
severity: normal
status: open
title: Significant performance problems with Python 2.7 built with clang 3.x or
4.x
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32616>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com