Calling comprehensions always makes CALL_PY_EXACT_ARGS miss
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza rastreando la especialización CALL_PY_EXACT_ARGS para las funciones creadas por MAKE_FUNCTION, centrándote en la comprobación DEOPT_IF func_version descrita en el issue. Usa el ejemplo de desensamblado como reproducer y compara los resultados de pyperformance; se considera terminado cuando estas llamadas de comprensiones se eviten estáticamente o dejen de fallar innecesariamente, sin regresión en el benchmark indicado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- performance
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100