Skip to content

Pytest-cov is extremely slow with xdist too #669

Open

Description

@emjeyforta

Please go over all the sections and search
https://pytest-cov.readthedocs.io/en/latest/ or
https://coverage.readthedocs.io/en/latest/
before opening the issue.

Summary

When I run our tests with pytest-xdist, our entire tests about 1035 of them gets done in less than 35min
However, when we use pytest-cov it takes upto 1hr:15min which is tremondous.

I understand this is also due to the fact that the code instrumentation process of tracking the code takes some amount of time but this feels pretty exorbitant.

I also tried to install the python3-dev package but this does not seem to help as well

RUN apt-get update && \
    apt-get install -y python3-dev build-essential && \
    rm -rf /var/lib/apt/lists/*

With the above command, I see that it has made CTRACER available as well.

# python -c "import coverage; print(coverage.tracer.CTracer.__doc__)"
CTracer objects

We run our tests within the docker container.

Expected vs actual result

Pytest-cov should be able to complete the tests in and around the time when run without it

Activity

  1. KristianOellegaard commented on Jan 20, 2025

    @KristianOellegaard

    I'm experiencing the same thing after moving our tests to run inside a docker container. I suspect Docker might be the problem.

  2. webknjaz commented on Aug 18, 2025

    @webknjaz
    Member

    pytest-cov is just a thin wrapper around coveragepy, it can't magically make coveragepy fast. I think that newer CPython versions will have better line tracing APIs that coveragepy could eventually make use of. But as it is, this issue does not have any evidence of being related to this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions