Skip to content

clang -Og takes 2 minutes to build a C program vs 6 seconds for clang -O3, and uses 1.8 GiB of memory #179695

@vstinner

Description

@vstinner

Building (the main branch of) Python with clang 21 fails randomly with a timeout of 20 minutes. I identified that the build is especially slow for Python/ceval.c and Modules/_testinternalcapi/interpreter.c. I built interpreter.c with -E to create a reproducer:

Reproducer: bug.c

On my Fedora 43 laptop (x86-64) with clang 21.1.8:

  • -O3: time clang -c -O3 bug.c -o bug takes 6 seconds, and consumes around 202 MiB of RSS memory
  • -Og: time clang -c -Og bug.c -o bug takes 2 minutes 45 seconds => 28x slower, and consumes up to 1.8 GiB of RSS memory (9x more)

clang -O0, clang -O1 and clang -O2 take between 1 and 6 seconds.

I cannot reproduce this issue on a Fedora ppc64le machine with clang 20.1.8:

  • -Og: 17.5 seconds
  • -O3: 18.9 seconds

How can I help you to debug this issue?

I'm trying to reduce the reproducer program, but so far I failed to reduce the Test_EvalFrame() function (17k lines).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions