python / python/cpython

Sampling profiler fails to display user-defined function in IDLE when started with the run command

Aberta
#142,325 5 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

3.15 stdlib topic-profiling type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

This is my simple test running IDLE at profiler startup (sudo as I'm running on a Mac, YMMV):

sudo -E ./python.exe -m profiling.sampling run -a --realtime-stats -d 99999 --live -m idlelib

As expected, I can also attach to a running IDLE session:

sudo -E ./python.exe -m profiling.sampling attach -a --realtime-stats -d 99999 --live <PID>

The two versions display things differently. If I attach to a running IDLE, define fib(), then call it with a large n (say, 200), it will run for a while before returning a result. I can see the recursive calls to fib in the display.

Image

If I use the run command instead, I never see fib show in the display. Instead, I see something like this:

Image

It appears all the samples in fib are credited to Misc.mainloop. I know the function is executing, given that small-n calls return quickly with the correct result, but shouldn't fib show up in the display when called with a large value for n if I use the run command to start IDLE?

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

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

Reproduza a diferença entre os comandos profiling.sampling run e attach em relação ao idlelib, usando uma chamada recursiva a fib() conforme descrito. Comece rastreando como profiling.sampling trata o caminho run e compare as amostras exibidas com attach; estará concluído quando funções definidas pelo usuário, como fib, aparecerem na exibição de run em vez de serem atribuídas a Misc.mainloop.

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

Avaliação

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

Receba novas issues na sua caixa de entrada

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