[New-bugs-announce] [issue46600] Python built with clang -O0 allocates 10x more stack memory than clang -O3 on a Python function call

STINNER Victor report at bugs.python.org
Tue Feb 1 08:06:00 EST 2022


New submission from STINNER Victor <vstinner at python.org>:

Measure using this script on the main branch (commit 108e66b6d23efd0fc2966163ead9434b328c5f17):
---
import _testcapi
def f(): yield _testcapi.stack_pointer()
print(_testcapi.stack_pointer() - next(f()))
---

Stack usage depending on the compiler and compiler optimization level:

* clang -O0: 9,104 bytes
* clang -Og: 736 bytes
* gcc -O0: 6,784 bytes
* gcc -Og: 624 bytes

-O0 allocates around 10x more memory.

Moreover, "./configure --with-pydebug CC=clang" uses -O0 in CFLAGS, because "clang --help" output doesn't containt "-Og". I'm working on a configure change to use -Og on clang which supports it.

----------
components: Build
messages: 412252
nosy: vstinner
priority: normal
severity: normal
status: open
title: Python built with clang -O0 allocates 10x more stack memory than clang -O3 on a Python function call
type: performance
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46600>
_______________________________________


More information about the New-bugs-announce mailing list