GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pytester: avoid unraisableexception gc collects in inline runs to speed up test suite by bluetech · Pull Request #13525 · pytest-dev/pytest

Conversation

@bluetech

@bluetech bluetech commented Jun 16, 2025 •
edited by nicoddemus
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is an alternative to #13513. I had to change some tests to run in a subprocess and tweak them a bit to make it work.

Fixes #13482.

Closes #13513.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bluetech and others added 2 commits June 16, 2025 21:43
@bluetech @nicoddemus
pytester: avoid unraisableexception gc collects in inline runs to spe…
4a73ab6
…ed up test suite

Because `pytester.runpytest()` executes the full session cycle (including
`pytest_unconfigure`), it was calling `gc.collect()` in a loop multiple
times—even for small, fast tests. This significantly increased the total
test suite runtime.

To optimize performance, disable the gc runs in inline pytester runs
entirely, matching the behavior before pytest-dev#12958.

Locally the test suite runtime improved dramatically, dropping from 425s
to 160s.

Fixes pytest-dev#13482.

Co-authored-by: Bruno Oliveira <[email protected]>
@nicoddemus
Move import to local to fix cicular import
efbe10a
@nicoddemus nicoddemus added skip news used on prs to opt out of the changelog requirement backport 8.4.x labels Jun 16, 2025
nicoddemus
nicoddemus approved these changes Jun 16, 2025
View reviewed changes

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nicoddemus
nicoddemus merged commit 391324e into pytest-dev:main Jun 16, 2025
@patchback

patchback Bot commented Jun 16, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Backport to 8.4.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/8.4.x/391324e13a6589f5d824d053240d4b9a4139a115/pr-13525

Backported as #13526

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

patchback Bot pushed a commit that referenced this pull request Jun 16, 2025
@bluetech @nicoddemus @patchback
pytester: avoid unraisableexception gc collects in inline runs to spe…
0b56e52
…ed up test suite (#13525)

Because `pytester.runpytest()` executes the full session cycle (including
`pytest_unconfigure`), it was calling `gc.collect()` in a loop multiple
times—even for small, fast tests. This significantly increased the total
test suite runtime.

To optimize performance, disable the gc runs in inline pytester runs
entirely, matching the behavior before #12958.

Locally the test suite runtime improved dramatically, dropping from 425s
to 160s.

Fixes #13482.

Co-authored-by: Bruno Oliveira <[email protected]>
(cherry picked from commit 391324e)
@patchback patchback Bot mentioned this pull request Jun 16, 2025
[PR #13525/391324e1 backport][8.4.x] pytester: avoid unraisableexception gc collects in inline runs to speed up test suite #13526
Merged
nicoddemus added a commit that referenced this pull request Jun 16, 2025
@patchback @bluetech @nicoddemus
pytester: avoid unraisableexception gc collects in inline runs to spe…
4c161ab
…ed up test suite (#13525) (#13526)

Because `pytester.runpytest()` executes the full session cycle (including
`pytest_unconfigure`), it was calling `gc.collect()` in a loop multiple
times—even for small, fast tests. This significantly increased the total
test suite runtime.

To optimize performance, disable the gc runs in inline pytester runs
entirely, matching the behavior before #12958.

Locally the test suite runtime improved dramatically, dropping from 425s
to 160s.

Fixes #13482.


(cherry picked from commit 391324e)

Co-authored-by: Ran Benita <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
@bluetech
bluetech deleted the pytester-no-gc-collects branch June 18, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nicoddemus nicoddemus nicoddemus approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[self-tests] test time degradation

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bluetech @nicoddemus
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.