Skip to content

Drop the suite profiler hook's unused argument - #2393

Closed
max-sixty wants to merge 8 commits into
mainfrom
reduce-suite-cost
Closed

max-sixty wants to merge 8 commits into
mainfrom
reduce-suite-cost

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#2345 landed beside the vulture pre-commit hook, which flags nextitem in leaf_dev.suite_profile.pytest_runtest_protocol as unused, so main's lint fails at 39f03c8. pluggy passes a hook implementation only the arguments it names, so the hook now takes item alone. A run with the plugin still writes each test's profile property.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 8 commits October 10, 2026 20:40
The complete suite's test job takes about four hours and its junit report records
one total per test, so nothing said how a browser test's ~8.5 s splits between
setup, page preparation, waiting on the browser, and the test's own Python.

The test job now records three readings beside the junit report and prints a
summary of them into the job summary:

- `leaf_dev.suite_profile`, a pytest plugin in addopts, gives each test a junit
  `profile` property: its setup, call and teardown seconds, and its time in
  Playwright's sync API keyed by method and calling frame. Playwright runs its event
  loop in a second greenlet, so a sampling profiler sees a browser wait as an idle
  event loop with the test off the stack; timing each call where it is made keeps
  the attribution.
- py-spy samples every Python process the run starts at 20 Hz, waits included,
  for the suite's own Python by function.
- BSD process accounting gives the run's CPU by command, for Chrome, Node and the
  servers no Python stack shows. The job is CPU-bound, so this is where the
  runner's capacity goes.

`leaf-dev suite-profile DIR` reads the three from a downloaded `pytest-results-*`
artifact.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The PR run's stacks held command lines with newlines and bytes that are not UTF-8,
which the line-by-line reader rejected. At 20 Hz py-spy took 16 of the run's 157 CPU
minutes; 5 Hz keeps thousands of samples an hour per worker.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
At 5 Hz py-spy still took 4.5% of the PR run's CPU. The job's PY_SPY_RATE now sets
both py-spy's rate and the rate leaf-dev suite-profile turns samples into minutes
with.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ild processes

The wrapper's frame sat between Playwright and the caller, so Playwright's traces
and protocol metadata named the profiler as each call's site; its code is now filed
under Playwright's package, which that attribution skips. A call failure with a
teardown error is two junit cases, the profile on the second; the summary now reads
them as one test. The summary also lists the Python processes tests start, whose
work a test's own stack shows only as a wait.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Process accounting is machine-wide, and a pull request's job builds the website
beside the suite, so its table mixed the two. Main, the schedule and a dispatch
run nothing else meanwhile.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A py-spy that could not attach or sample left the job green with no stacks, and the
summary skips a missing stacks.txt, so the reading would vanish unnoticed. The job
now fails, keeping pytest's own failure status where it has one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's vulture hook, which arrived beside #2345, flags it; pluggy passes a hook
implementation only the arguments it names.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 11, 2026
Reuse the bounded CI correction from #2393: pluggy supplies only named hook arguments, so the unused nextitem parameter is unnecessary. Verified that passing browser cases still emit their profile properties.
@max-sixty max-sixty closed this Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants