Make -fprofile-update=atomic opt-in for PGO builds to avoid 34% slowdown by builtbyashwin · Pull Request #157026 · python/cpython · GitHub
Skip to content

Make -fprofile-update=atomic opt-in for PGO builds to avoid 34% slowdown - #157026

Closed
builtbyashwin wants to merge 1 commit into
python:mainfrom
builtbyashwin:fix/pgo-atomic-slow-build
Closed

Make -fprofile-update=atomic opt-in for PGO builds to avoid 34% slowdown#157026
builtbyashwin wants to merge 1 commit into
python:mainfrom
builtbyashwin:fix/pgo-atomic-slow-build

Conversation

@builtbyashwin

Copy link
Copy Markdown

Problem

The -fprofile-update=atomic flag in PGO_PROF_GEN_FLAG causes severe lock contention during PGO builds, making them 34% slower on multi-core machines.

Benchmark (on T430, compiling Python/ceval.c)

  • Without flag: 5.813s
  • With flag: 7.775s
  • Slowdown: ~34%

Fix

Made -fprofile-update=atomic opt-in via a new AC_ARG_ENABLE([pgo-atomic]) option in configure.ac. Default is now -fprofile-generate only, which is significantly faster.

Usage

  • Default: ./configure --enable-optimizations (no atomic flag, faster)
  • Opt-in: ./configure --enable-optimizations --enable-pgo-atomic (safe for users who need atomic profiling)

Compatibility

Backwards-compatible. Users who need the atomic flag can still enable it via the new configure option.

Verification

Ran make -j2 successfully after the change. 0 failed on import.

@python-cla-bot

python-cla-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

@bedevere-app

bedevere-app Bot commented Sep 6, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland

Copy link
Copy Markdown
Member

Please open an issue first, also specify what impact will this have on performance, we want PGO builds to be optimised after all.

@StanFromIreland StanFromIreland added the pending The issue will be closed if no feedback is provided label Sep 6, 2026
@Fidget-Spinner

Copy link
Copy Markdown
Member

@picnixz picnixz closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review pending The issue will be closed if no feedback is provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants