classification
Title: Use -Og for debug builds
Type: enhancement Stage: resolved
Components: Build, Tests Versions: Python 3.5, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: haypo, pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-02-11 16:28 by pitrou, last changed 2015-03-27 14:48 by haypo. This issue is now closed.

Files
File name Uploaded Description Edit
og.patch pitrou, 2015-02-11 16:28 review
Messages (10)
msg235754 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-02-11 16:28
Recent gcc versions have an optimization level named "-Og". It enables all optimizations that do not break debugging. Here is a patch that uses it on debug builds.

Without the patch I get the following time for the whole test suite:

$ time ./python -m test -j12
[...]
real	3m51.670s
user	11m53.039s
sys	0m28.300s

With the patch it goes down to:

real	2m36.378s
user	7m13.743s
sys	0m29.728s

So the test suite is 33% faster to pass.
msg235755 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-11 16:44
Most slow tests are skipped without -uall.

As for the patch, may be use AX_CHECK_COMPILE_FLAG [1]?

[1] http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
msg235756 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-02-11 17:10
-uall, without patch:

real	5m47.290s
user	18m28.405s
sys	0m29.493s

-uall, with patch:

real	3m35.132s
user	10m26.345s
sys	0m30.351s

That's a 38% speedup.
msg235757 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-02-11 17:11
> As for the patch, may be use AX_CHECK_COMPILE_FLAG [1]?

It's not used elsewhere in configure.ac. I reused the idiom used a couple lines above.
msg235759 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-11 18:00
This looks pretty harmless. Some slow buildbots run tests very long time and failed with timeout after 3600 seconds. May be this patch will make them faster.

Yet one advantage -- the code compiled with partial optimization will be closer to the code compiled with full optimization. Therefore debugging version could catch more bugs that exist only with optimization.

But may be apply this only to 3.5?
msg235760 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-02-11 18:03
I'd like to apply it to 3.4 as well, because it makes development more pleasant.
msg235763 - (view) Author: Roundup Robot (python-dev) Date: 2015-02-11 18:41
New changeset e37b201297d2 by Antoine Pitrou in branch '3.4':
Issue #23445: pydebug builds now use "gcc -Og" where possible, to make the resulting executable faster.
https://hg.python.org/cpython/rev/e37b201297d2

New changeset 527ed5205806 by Antoine Pitrou in branch 'default':
Issue #23445: pydebug builds now use "gcc -Og" where possible, to make the resulting executable faster.
https://hg.python.org/cpython/rev/527ed5205806
msg235764 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-02-11 18:41
Done. It shouldn't break anything.
msg239406 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-27 14:44
New changeset c663dbb84c8c by Victor Stinner in branch '3.4':
Issue #23445: Fix test.support.python_is_optimized() for CFLAGS=-Og
https://hg.python.org/cpython/rev/c663dbb84c8c

New changeset 5b5a22b9327b by Victor Stinner in branch '2.7':
Issue #23445: Fix test_gdb.python_is_optimized() for CFLAGS=-Og
https://hg.python.org/cpython/rev/5b5a22b9327b
msg239407 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2015-03-27 14:48
> Done. It shouldn't break anything.

You're change skipped some test_gdb tests. I fixed the check in test_gdb/test.support.
History
Date User Action Args
2015-03-27 14:48:51hayposetnosy: + haypo
messages: + msg239407
2015-03-27 14:44:55python-devsetmessages: + msg239406
2015-02-11 18:41:42pitrousetstatus: open -> closed
resolution: fixed
messages: + msg235764

stage: patch review -> resolved
2015-02-11 18:41:20python-devsetnosy: + python-dev
messages: + msg235763
2015-02-11 18:03:00pitrousetmessages: + msg235760
2015-02-11 18:00:01serhiy.storchakasetmessages: + msg235759
2015-02-11 17:11:02pitrousetmessages: + msg235757
2015-02-11 17:10:31pitrousetmessages: + msg235756
2015-02-11 16:44:09serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg235755
2015-02-11 16:28:42pitroucreate