Calling comprehensions always makes CALL_PY_EXACT_ARGS miss
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 38/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
- 領域
- performance
研究方向
先追蹤由 MAKE_FUNCTION 建立的函式所使用的 CALL_PY_EXACT_ARGS 特化,重點關注 issue 中描述的 DEOPT_IF func_version 檢查。使用反組譯範例作為 reproducer,並比較 pyperformance 結果;當這些 comprehension 呼叫能在靜態階段被避免,或不再不必要地 miss,且報告中的 benchmark 沒有回歸時,即視為完成。
由索引模型根據 Issue 內容生成。
描述
Consider the function
def f():
return [x for x in range(2)]
for i in range(20):
f() # warmup
from dis import dis
dis(f, adaptive=True)
dis(f)
1 0 RESUME_QUICK 0
2 2 LOAD_CONST 1 (<code object <listcomp> at 0x000001DA71743920, file "<stdin>", line 2>)
4 MAKE_FUNCTION 0
6 LOAD_GLOBAL_BUILTIN 1 (NULL + range)
18 LOAD_CONST 2 (2)
20 CALL_BUILTIN_CLASS 1
30 GET_ITER
32 CALL_PY_EXACT_ARGS 0
42 POP_TOP
44 LOAD_CONST 0 (None)
46 RETURN_VALUE
Disassembly of <code object <listcomp> at 0x000001DA71743920, file "<stdin>", line 2>:
2 0 RESUME_QUICK 0
2 BUILD_LIST 0
4 LOAD_FAST 0 (.0)
>> 6 FOR_ITER_RANGE 4 (to 18)
10 STORE_FAST__LOAD_FAST 1 (x)
12 LOAD_FAST 1 (x)
14 LIST_APPEND 2
16 JUMP_BACKWARD_QUICK 6 (to 6)
>> 18 RETURN_VALUE
That CALL_PY_EXACT_ARGS always misses at
DEOPT_IF(func->func_version != read_u32(cache->func_version), CALL);
because the function is created by MAKE_FUNCION so it will never have the same func_version as the previous time.
CALL_PY_EXACT_ARGS misses roughly 5% of the time in pyperformance, and this might decrease that a hair.
Maybe this is insignificant enough that it won't matter, but it would theoretically be nice to statically decide not to specialize these calls.
cc @markshannon
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 平均合併
- 1 天 9 小時
- 30 天內合併 PR
- 558
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/cpython 的其他 Issue
-
docs pending
難度 2/5 1-3 小時 新手友好度 78/100
-
stdlib type-feature
難度 2/5 1-3 小時 新手友好度 78/100
-
stdlib type-feature
難度 2/5 1-3 小時 新手友好度 72/100
-
build type-bug
難度 2/5 1-3 小時 新手友好度 76/100
-
stdlib topic-email type-feature
難度 2/5 1-3 小時 新手友好度 70/100
相似的 Issue
-
link-check link-check:sphinx-theme
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難度 2/5 1-3 小時 新手友好度 88/100
OpenHands/extensions#626 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
CSCfi/sd-search-api#39 ·
-
難度 1/5 1 小時以內 新手友好度 90/100