python / python/cpython

perf_jit activated from a subinterpreter publishes JIT executors with the trampoline's unwind info

Aberta
#157,247 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

interpreter-core topic-JIT type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
35.9k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

sys.activate_stack_trampoline() refuses to run while the JIT is active, but it only checks the current interpreter, and the perf state is process-wide. A subinterpreter can activate perf_jit while the main interpreter keeps its JIT.

import sys
from concurrent import interpreters

interpreters.create().exec("import sys; sys.activate_stack_trampoline('perf_jit')")

def hot(n):
    t = 0
    for i in range(n):
        t += i & 3
    return t

for _ in range(50):
    hot(100000)

With PYTHON_JIT=1 ./python buggy_stuff.py on a --enable-experimental-jit build, the resulting /tmp/jit-.dump holds the JIT's executors (records named py::jit:executor), and every one of them is tagged with the unwind information of the 8-byte perf trampoline. Executor frames look different, so perf produces wrong stacks for samples inside JIT code.

Found while working on https://github.com/python/cpython/pull/157246

CPython versions tested on:

CPython main branch, 3.16

Operating systems tested on:

Linux

Linked PRs
  • gh-157258
  • gh-157324

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece com sys.activate_stack_trampoline(), a opção perf_jit e a reprodução com subinterpreter descrita na issue; execute isso em um build Linux com JIT experimental e PYTHON_JIT=1 e inspecione o /tmp/jit-.dump gerado. Rastreie como os executores JIT recebem informações de unwind e considere a issue resolvida quando os frames dos executores não forem mais marcados com os dados de unwind do trampoline perf de 8 bytes.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
compilers, performance
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.