Re-enable PGO on the Alpine variants now that python/cpython#90548 is closed?

未關閉 適合新手
#1,151 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
76/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
docker
領域
build-system

研究方向

閱讀 Dockerfile-linux.template 中約第 206–212 行的 is_alpine 條件,以及 #980 中相關的上下文。所要求的變更是移除該條件,讓 Alpine 建置使用 --enable-optimizations。該 issue 回報在 x86_64 Alpine 3.24 上使用 CPython 3.14.10 成功完成 PGO 訓練,但其他版本和架構尚未測試。完成標準是 Alpine 變體啟用 PGO,且其訓練執行成功。

由索引模型根據 Issue 內容生成。

描述

Hey there, thanks for maintaining these images, I run the Alpine variants in production.

Could the Alpine variants build with --enable-optimizations again? #980 turned it off in October 2024 because test_math and test_re failed in the PGO training run (python/cpython#90548). That issue was closed as completed in September 2025, and the training run now passes for me on 3.14/alpine3.24.

It would only mean removing the is_alpine condition in Dockerfile-linux.template, with no patch to carry. Happy to send that PR if you'd like it.

python -m test --pgo on CPython 3.14.10, x86_64 Test files passed test_math test_re
Published python:3.14-alpine3.24, run in the container 43 of 43 passed passed
3.14/alpine3.24 plus --enable-optimizations, the training run inside make 43 of 43 passed passed

On pyperformance the build with the flag is 1.19x faster than the published image. It takes the build step from 128 s to 313 s on a 12-thread x86_64 host. I could only test x86_64 and 3.14.

What I changed and ran

The Dockerfile is 3.14/alpine3.24/Dockerfile at 3a144d79062aa1f59d2e4e99fc96aec3b5871e72 with one line added to the ./configure call:

 		--enable-loadable-sqlite-extensions \
+		--enable-optimizations \
 		--enable-option-checking=fatal \
$ docker build --progress=plain --no-cache -t py314-alpine-pgo .
...
#6 121.5 LD_LIBRARY_PATH=/usr/src/python ./python -m test --pgo --timeout=
...
#6 189.3 0:01:07 load avg: 4.52 [27/43] test_math passed
...
#6 206.7 0:01:24 load avg: 3.74 [34/43] test_re passed
...
#6 242.3 Total tests: run=9,964 skipped=265
#6 242.3 Result: SUCCESS
...
#6 DONE 312.5s

The same docker build --no-cache of the unchanged Dockerfile ends with #6 DONE 127.9s.

The resulting interpreter reports the flag and the profile flags:

$ docker run --rm py314-alpine-pgo python3 -c 'import sysconfig; print(sysconfig.get_config_var("CONFIG_ARGS"))'
'--build=x86_64-linux-musl' '--enable-loadable-sqlite-extensions' '--enable-optimizations' '--enable-option-checking=fatal' '--enable-shared' '--with-lto' '--with-ensurepip' 'build_alias=x86_64-linux-musl'

PY_CFLAGS_NODIST contains -fprofile-use in this build and not in the published python:3.14-alpine3.24.

The published image deletes the test suite, so for the first row I copied Lib/test from the 3.14.10 source tarball into the container and ran the same test set:

$ docker run --rm python:3.14-alpine3.24 sh -c '... cp -r Python-3.14.10/Lib/test /usr/local/lib/python3.14/test; python3 -m test --pgo --timeout=1200'
0:00:14 load avg: 1.13 [27/43] test_math passed
0:00:17 load avg: 1.12 [34/43] test_re passed
...
Total tests: run=9,964 skipped=265
Total test files: run=43/43
Result: SUCCESS

For speed, I ran pyperformance 1.14.0 in each image, pinned to one CPU core, on an x86_64 laptop under WSL2, one image after the other:

$ python3 -m pyperf compare_to published.json pgo.json --table -G
...
| Geometric mean                   | (ref)     | 1.19x faster           |

Of the 124 benchmarks, 114 are faster and 4 are slower: base16_large 1.10x, asyncio_tcp 1.06x, asyncio_tcp_ssl 1.02x and dask 1.02x. pyperf reports the other 6 as not significant.

Related:

  • #160, the original request for --enable-optimizations
  • #979, which found PGO had been skipped on every variant
主要語言
Dockerfile
星號
2.8k
分支
1.1k
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

docker-library/python 的其他 Issue

查看 docker-library/python 的全部 Issue

相似的 Issue

更多 Build System Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。