Cut the 3 s pytest startup without a warm process

オープン
#227 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
34/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
0
フォーク
0
平均マージ
2時間 9分
マージ済み PR(30日)
164

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

neurodata/prolearn のほかの issue

neurodata/prolearn の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。