python / python/cpython

`test_profiling` sometimes times out under TSan

Aberta
#143,442 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

tests 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

We don't currently run test_profiling in the TSan CI, but the context is that I'm trying to get the entire test suite running under thread sanitizer (TSan).

Some of the tests in test_profiling fail to attach in time when run with thread sanitizer, because the sanitizer makes everything slower. This is especially the case when running tests in parallel with -j.

Here's a example:

ERROR: test_run_failed_script_live (test.test_profiling.test_sampling_profiler.test_live_collector_ui.TestLiveModeErrors.test_run_failed_script_live)
Test that running a failing script exits with clean error.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 279, in _run_with_sync
    _wait_for_ready_signal(sync_sock, process, _SYNC_TIMEOUT_SEC)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 223, in _wait_for_ready_signal
    raise socket.timeout("timed out")
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 1110, in _handle_live_run
    process = _run_with_sync(cmd, suppress_output=True)
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 289, in _run_with_sync
    raise RuntimeError(
        "Process failed to signal readiness within timeout"
    )
RuntimeError: Process failed to signal readiness within timeout

I think the problem is that the the _SYNC_TIMEOUT_SEC of 5 seconds isn't enough in this case:

https://github.com/python/cpython/blob/4f9a8d075ee52b8f56aca14102c8bf9fd6f3c512/Lib/profiling/sampling/cli.py#L78

Here are some options to consider:

  1. Make _SYNC_TIMEOUT_SEC configurable via a command line option and specify a larger value for the tests (i.e., SHORT_TIMEOUT)
  2. Make _SYNC_TIMEOUT_SEC configurable via environment variable
  3. Skip these tests under TSan
  4. ???

cc @pablogsal

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 em Lib/profiling/sampling/cli.py, em _SYNC_TIMEOUT_SEC e _wait_for_ready_signal, e depois inspecione o caso com falha de test_profiling, test_run_failed_script_live. Execute os testes de profiling sob TSan, incluindo a execução paralela com -j, e compare as convenções existentes dos testes para comportamento específico de sanitizer. A tarefa estará concluída quando os testes afetados forem concluídos de forma confiável sob TSan sem enfraquecer a cobertura normal dos testes.

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

Avaliação

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

Receba novas issues na sua caixa de entrada

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