You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently added a Python 3.12-dev build to a project where I enable coverage on all the CI test runs, and the 3.12 build has consistently been taking nearly twice a long to complete as the 3.8-3.11 builds.
I made a test PR disabling coverage and the issue went away. Obviously without coverage the tests run faster, but the point is that the different Python versions all ran in about the same time.
I haven't yet tried to install Python 3.12 to see if I can reproduce this locally, but the performance hit is pretty consistent on CI (you can see it on pretty much every recent build in Quansight-Labs/ndindex#155 for example).
Happy to provide more info, and try to repro locally if you can suggest an easy way to install a Python 3.12 environment. The package in question is pure Python, but the tests depend heavily on both numpy (I've been installing 3.12-compatible dev wheels from https://pypi.anaconda.org/scientific-python-nightly-wheels/simple) and hypothesis.
I mostly just wanted to make sure was on your radar since I didn't see any other issues about it.
This is a mystery. I forked your repo (https://github.com/nedbat/ndindex) and hacked away at it. Now I have a file (justdoit.py) that sets a do-nothing trace function, and runs one of your tests: https://github.com/nedbat/ndindex/actions/runs/5767689409. On 3.11, it takes 14sec. On 3.12, it takes 43sec. I don't know why. We could toss this over to CPython to diagnose. They will probably want to take a look.
On 3.11, it takes 14sec. On 3.12, it takes 43sec. I don't know why. We could toss this over to CPython to diagnose. They will probably want to take a look.
This is with the C extension? At CPython they had a look and didn't do anything for 3.12.0. There are some hopes that coveragepy will switch to the new monitoring API for 3.12 but I didn't find any trace supporting that hope here in coveragepy repo. Is there hope :)? python/cpython#107841 (comment)
I've pinged the core dev on the CPython issue. I have started on code to use the new PEP 669 monitoring, but I haven't made much progress on it. I'd welcome help.
For anyone else still struggling with this and who missed the changelog:
coverage 7.4.0 includes experimental support for PEP 669 that can be enabled with COVERAGE_CORE=sysmon environment variable, which already speeds up line coverage.
Reacted by Saul Shanabrook, Niels Lemmens, Lev Gorodetskii, Giovanni M Guidini, Willi Sontopski, Andrey Rakhmatullin and Fabricio Lemos
Reacted by Alexander Beedie, Willi Sontopski and Niko Föhr
Thanks for the tip. This would be a lot easier to use if that variable were just ignored for Python 3.11 and lower. Right now, setting it causes those versions to raise an exception.
Contrary to what others reported, the COVERAGE_CORE=sysmon option seems to degrade performance even further when running the scikit-learn tests with coverage enabled on CPython 3.12 (at least under Linux):
Activity
nedbat commentedon Aug 4, 2023
The first thing to check is whether 3.12 has the C extension available.
coverage --helpwill show:or:
asmeurer commentedon Aug 4, 2023
It apparently does: https://github.com/Quansight-Labs/ndindex/actions/runs/5766363872/job/15634144314?pr=161#step:5:30. It looks like there are 3.12 manylinux builds on pypi https://pypi.org/project/coverage/#files, so it is grabbing that.
asmeurer commentedon Aug 4, 2023
Here's
coverage debug sys:(from https://github.com/Quansight-Labs/ndindex/actions/runs/5766385439/job/15634216577?pr=161#step:5:48)
nedbat commentedon Aug 5, 2023
This is a mystery. I forked your repo (https://github.com/nedbat/ndindex) and hacked away at it. Now I have a file (justdoit.py) that sets a do-nothing trace function, and runs one of your tests: https://github.com/nedbat/ndindex/actions/runs/5767689409. On 3.11, it takes 14sec. On 3.12, it takes 43sec. I don't know why. We could toss this over to CPython to diagnose. They will probably want to take a look.
nedbat commentedon Aug 5, 2023
I've reported this in CPython: python/cpython#107674
tarpas commentedon Oct 24, 2023
This is with the C extension? At CPython they had a look and didn't do anything for 3.12.0. There are some hopes that coveragepy will switch to the new monitoring API for 3.12 but I didn't find any trace supporting that hope here in coveragepy repo. Is there hope :)? python/cpython#107841 (comment)
nedbat commentedon Oct 24, 2023
I've pinged the core dev on the CPython issue. I have started on code to use the new PEP 669 monitoring, but I haven't made much progress on it. I'd welcome help.
intgr commentedon Feb 10, 2024
For anyone else still struggling with this and who missed the changelog:
coverage 7.4.0 includes experimental support for PEP 669 that can be enabled with
COVERAGE_CORE=sysmonenvironment variable, which already speeds up line coverage.asmeurer commentedon Feb 12, 2024
Thanks for the tip. This would be a lot easier to use if that variable were just ignored for Python 3.11 and lower. Right now, setting it causes those versions to raise an exception.
7 remaining items
ogrisel commentedon Jul 10, 2024
Contrary to what others reported, the
COVERAGE_CORE=sysmonoption seems to degrade performance even further when running the scikit-learn tests with coverage enabled on CPython 3.12 (at least under Linux):Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
improve performance of tests in Python>=3.12 when used with coverage
improve performance of tests in Python>=3.12 when used with coverage
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…
Improve speed and stability of Python 3.12 tests in canary build (#38…