-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set COVERAGE_CORE: sysmon
for faster tests on 3.12+
#7820
Conversation
Is the reason it's not yet the default, and why https://coverage.readthedocs.io/en/7.4.2/changes.html#version-7-4-0-2023-12-27 lists it as "experimental", just because branch coverage isn't faster? Or is there another reason? |
Yeah, I think it's both because of branch coverage, and because it's new and using new Python features, so feedback is requested. If we find any problems, we can give feedback, and easily disable if necessary. |
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.
I see that it is faster on AppVeyor, macOS and Ubuntu.
I find it harder to say conclusively that it is faster in Windows on GitHub Actions, but if it is theoretically, then ok.
Here's three runs of Windows on GitHub Actions with
https://github.com/hugovk/Pillow/actions/runs/7941332092/attempts/1 Then with the PR:
https://github.com/hugovk/Pillow/actions/runs/7986985726/attempts/1 |
Despite passing on main a mere 11 hours ago, this has started failing in PyPy on Windows - https://github.com/python-pillow/Pillow/actions/runs/8016398970/job/21898259794 |
Python 3.12 introduced sys.monitoring, that tools like coverage.py can use to improve performance.
It's not yet the default in coverage.py. To enable, we can set a
COVERAGE_CORE=sysmon
environment variable, that will switch to the faster mode when available, that is, in Python 3.12 and newer. Older versions will stick to the older method.For example, on my machine:
python3 -m pytest Tests
python3 -m pytest --cov PIL --cov Tests Tests
COVERAGE_CORE=sysmon python3 -m pytest --cov PIL --cov Tests Tests
Coverage time on CI, default core -> sysmon core:
I also added the env var to the Cygwin and MinGW workflows, even though they test Python <= 3.11. If they're upgraded to 3.12+ later, it'll take effect.