<div dir="ltr"><div>After much testing I found what is causing the regression in 16.04 and later.  There are several distinct causes which are attributed to the choices made in debian/rules and the changes in GCC.<br><br>Cause #1: the decision to compile `Modules/_math.c` with `-fPIC` *and* link it statically into the python executable [1].  This causes the majority of the slowdown.  This may be a bug in GCC or simply a constraint, I didn't find anything specific on this topic, although there are a lot of old bug reports regarding the interaction of -fPIC with -flto.<br><br>Cause #2: the enablement of `fpectl` [2], specifically the passage of `--with-fpectl` to `configure`.  fpectl is disabled in <a href="http://python.org">python.org</a> builds by default and its use is discouraged.  Yet, Debian builds enable it unconditionally, and it seems to cause a significant performance degradation.  It's much less noticeable on 14.04 with GCC 4.8.0, but on more recent releases the performance difference seems to be larger.<br><br>Plausible Cause #3: stronger stack smashing protection in 16.04, which uses --fstack-protector-strong, whereas 14.04 and earlier used --fstack-protector (with lesser performance overhead).<br><br>Also, debian/rules limits the scope of PGO's PROFILE_TASK to 377 test suites vs upstream's 397, which affects performance somewhat negatively, but this is not definitive.  What are the reasons behind the trimming of the tests used for PGO?<br><br>Without fpectl, and without -fPIC on _math.c, 2.7.12 built on 16.04 is slower than stock 2.7.6 on 14.04 by about 0.9% in my pyperformance runs [3].  This is in contrast to a whopping 7.95% slowdown when comparing stock versions.<br><br>Finally, a vanilla Python 2.7.12 build using GCC 5.4.0, default CFLAGS, default PROFILE_TASK and default Modules/Setup.local consistently runs faster in benchmarks than 2.7.6 (by about 0.7%), but I was not able to pinpoint the exact reason for this difference.<br><br>Note: the percentages above are the relative change in the geometric mean of pyperformance benchmark results.<br><br><br>[1] <a href="https://git.launchpad.net/~usd-import-team/ubuntu/+source/python2.7/tree/debian/rules?h=ubuntu/xenial-updates#n421">https://git.launchpad.net/~usd-import-team/ubuntu/+source/python2.7/tree/debian/rules?h=ubuntu/xenial-updates#n421</a><br><br>[2] <a href="https://git.launchpad.net/~usd-import-team/ubuntu/+source/python2.7/tree/debian/rules?h=ubuntu/xenial-updates#n117">https://git.launchpad.net/~usd-import-team/ubuntu/+source/python2.7/tree/debian/rules?h=ubuntu/xenial-updates#n117</a><br><br>[3] <a href="https://docs.google.com/spreadsheets/d/1L3_gxe-AOYJsXFwGZgFko8jaChB0dFPjK5oMO5T5vj4/edit?usp=sharing">https://docs.google.com/spreadsheets/d/1L3_gxe-AOYJsXFwGZgFko8jaChB0dFPjK5oMO5T5vj4/edit?usp=sharing</a><br></div><div><br><br>Elvis<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 3, 2017 at 10:27 AM, Louis Bouchard <span dir="ltr"><<a href="mailto:louis.bouchard@canonical.com" target="_blank">louis.bouchard@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<span class=""><br>
Le 03/03/2017 à 15:37, Louis Bouchard a écrit :<br>
> Hello,<br>
><br>
> Le 03/03/2017 à 15:31, Victor Stinner a écrit :<br>
>>> Out of curiosity, I ran the set of benchmarks in two LXC containers running<br>
>>> centos7 (2.7.5 + gcc 4.8.5) and Fedora 25 (2.7.13 + gcc 6.3.x). The benchmarks<br>
>>> do run faster in 18 benchmarks, slower on 12 and insignificant for the rest (~33<br>
>>> from memory).<br>
>><br>
>> "faster" or "slower" is relative: I would like to see the ?.??x<br>
>> faster/slower or percent value. Can you please share the result? I<br>
>> don't know what is the best output:<br>
>>   python3 -m performance compare centos.json fedora.json<br>
>> or the new:<br>
>>   python3 -m perf compare_to centos.json fedora.json --table --quiet<br>
>><br>
>> Victor<br>
>><br>
><br>
> All the results, including the latest are in the spreadsheet here (cited in the<br>
> analysis document) :<br>
><br>
> <a href="https://docs.google.com/spreadsheets/d/1pKCOpyu4HUyw9YtJugn6jzVGa_zeDmBVNzqmXHtM6gM/edit#gid=1548436297" rel="noreferrer" target="_blank">https://docs.google.com/<wbr>spreadsheets/d/<wbr>1pKCOpyu4HUyw9YtJugn6jzVGa_<wbr>zeDmBVNzqmXHtM6gM/edit#gid=<wbr>1548436297</a><br>
><br>
> Third column is the ?.??x value that you are looking for, taken directly out of<br>
> the 'pyperformance analyze' results.<br>
><br>
> I didn't know about the new options, I'll give it a spin & see if I can get a<br>
> better format.<br>
<br>
</span>All the benchmark data using the new format have been uploaded to the<br>
spreadsheet. Each sheet is prefixed with pct_.<br>
<br>
HTH,<br>
<div class="HOEnZb"><div class="h5"><br>
Kind regards,<br>
<br>
...Louis<br>
<br>
<br>
--<br>
Louis Bouchard<br>
Software engineer, Cloud & Sustaining eng.<br>
Canonical Ltd<br>
Ubuntu developer                       Debian Maintainer<br>
GPG : 429D 7A3B DD05 B6F8 AF63  B9C4 8B3D 867C 823E 7A61<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/elprans%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>elprans%40gmail.com</a><br>
</div></div></blockquote></div><br></div>