Calling comprehensions always makes CALL_PY_EXACT_ARGS miss
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 36k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando la specializzazione CALL_PY_EXACT_ARGS per le funzioni create da MAKE_FUNCTION, concentrandoti sul controllo DEOPT_IF func_version descritto nell’issue. Usa l’esempio di disassembly come reproducer e confronta i risultati di pyperformance; il lavoro è completo quando queste chiamate alle comprehension vengono evitate staticamente o non falliscono più inutilmente, senza regressioni nel benchmark riportato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- performance
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100