Cut the 3 s pytest startup without a warm process

Abierto
#227 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
34/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start by profiling the fast tier with python -X importtime and pytest --collect-only, with xdist off and on, then compare against main and a --testmon run selecting a few tests. Use the results to recommend which startup cost to address first; the issue leaves the implementation choice and whether selection size should control worker count to the maintainer.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Starting four xdist workers and collecting the tests costs 3.1–3.4 s per run, even when no test runs. That is about half the fast tier's wall time. #220 considered a warm test process (pytest-hot-reloading) and turned it down: it is alpha, lists Python only up to 3.12, drops the xdist workers, and can return stale results.

Ways to try, each measured against main on the fast tier and on a --testmon run that selects a few tests:

  1. Profile the startup. Use python -X importtime and pytest --collect-only with xdist off and on, to split the 3 s into interpreter start, plugin loading, imports during collection (torch, matplotlib, jsonschema, sklearn), and worker boot.
  2. Defer heavy imports in test modules. Move module-level imports of torch, matplotlib and the experiment scripts into the tests or fixtures that use them, so that collection imports only what it needs.
  3. Skip xdist for small selections. When --testmon or -k leaves only a few tests, run them in one process, since booting four workers costs more than it saves. pytest-xdist's -n auto does not do this. A pytest_xdist_auto_num_workers hook or a conftest check could.
  4. Disable plugins the fast tier does not use, such as -p no: entries in addopts.

Questions for the maintainer:

  • Which of these to try first? Proposed default: 1, then whichever of 2–4 the profile points to.
  • Is changing worker count by selection size (3) acceptable, given that it makes a run's parallelism depend on how many tests it selects?

Refs #220.

Lenguaje dominante
Python
Estrellas
0
Forks
0
Merge medio
2 h 9 min
PR fusionados (30 d)
164

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de neurodata/prolearn

Todos los issues de neurodata/prolearn

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.