Performance issue with ARM64 windows Python release binaries
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
Hi Team,
I have an X-Elite laptop with an ARM64-based SoC, and I’ve been running Python workloads on it. However, I’ve noticed that Python seems to perform slower on Windows for ARM devices. To investigate, I used pybench, which provides a solid set of test cases for performance benchmarking. i have also taken intel x64 Lunarlake 258V device which has similar geekbench performance like X-Elite to see the performance delta.
Pybench : https://share.gtd-gmbh.de/d/7e9368c6350a4894bf8f/files/?p=%2FWorklets%2FPyBench%2Fpybench-for-3.10.tar.gz&dl=1
I collected the following results:
| Environment | Total Time (ms) |
|---|---|
| Windows on ARM64 | 802 |
| Windows on x64 | 507 |
| WSL2 (Linux on windows ARM64) | 515 |
To further analyze, I tested multiple Python versions and observed that earlier ARM64 Windows releases performed better than the latest one:
Python Version Comparison
| Version | Windows ARM64 (ms) | Windows x64 (ms) |
|---|---|---|
| 3.11.0 | 763 | 575 |
| 3.11.3 | 589 | Not tested |
| 3.11.6 | 590 | Not tested |
| 3.11.9 | 568 | Not tested |
| 3.12.0 | 666 | 545 |
| 3.12.5 | 688 | Not tested |
| 3.12.6 | 700 | Not tested |
| 3.12.7 | 802 | Not tested |
| 3.12.10 | 802 | 507 |
It’s clear that x64 performance has improved with each release, while ARM64 performance has been inconsistent, with a noticeable regression in the latest version.
I also cloned the Python 3.12.10 source and compiled it on the ARM64 Windows device using different compilers. I found that using clang-cl (19.1.2) with computed gotos enabled yielded significantly better performance than the official release:
Compiled vs. Released (Python 3.12.10)
| version | ARM64 (Release) | ARM64 (Compiled) |
|---|---|---|
| Python v3.12.10 (ms) | 802 | 628 |
Here i have question:
Can anybody please share the compilation steps (which compiler and flags) used to compile release ARM64 Windows binaries? If it is MSVC, is there any specific reason for not using clang-cl? Based on my experiment with pybench, I am seeing good results with clang-cl. Are there any other test cases we are running with release binaries where clang is not performing better?
Analysis:
I have tried to collect ETL logs in Windows and profile the test with Profile Explorer. The actual bottleneck I am seeing is in the compiler interpreter. The function python312.dll!_PyEval_EvalFrameDefault is the bottleneck.
CPython versions tested on:
CPython main branch, 3.12
Operating systems tested on:
Windows
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
報告沒有指出任何 CPython 檔案、測試或進入點。首先,在 Windows ARM64、Windows x64、WSL2 以及列出的 Python 版本上重現所提供的 pybench 比較;完成的標準是找出 ARM64 Windows 回歸的原因並記錄下來或修正它。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- operating-systems, performance
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 28/100