Skip to content
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

Update tests to use sysmon #16621

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

DarkaMaul
Copy link
Contributor

Coverage introduced in Coverage.py 7.4.0 the support for sys.monitoring.

While it should not work well with the branch coverage used within warehouse, tests on our computers with @woodruffw showed a significant improvement:

Tests results

  • With sysmon:
    • DarkaMaul : 26.7s
    • William: 29.36s
  • Baseline:
    • DarkaMaul: 56.38s
    • William: 50.08s

The relevant issue in coverage is nedbat/coveragepy#1812

We would like to gather more feedback before eventually pushing this option forward.

NOTE: The other tracers are ctrace or pytrace

/cc @woodruffw

@DarkaMaul DarkaMaul requested a review from a team as a code owner September 3, 2024 15:07
@woodruffw woodruffw added testing Test infrastructure and individual tests developer experience Anything that improves the experience for Warehouse devs labels Sep 3, 2024
Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

Thanks @DarkaMaul! I can confirm that this significantly speeds up the test suite in local runs for me.

I suspect coverage.py's branch performance regressions with sys.monitoring are pretty workload-dependent -- Warehouse is possibly just lucky enough to have a workload/layout that isn't causing significant issues relative to the baseline gains of using lightweight monitoring 🙂

@miketheman
Copy link
Member

Definitely cool speedup!

Looks like this has some impact on how contexts are measured?
https://github.com/pypi/warehouse/actions/runs/10685632141/job/29619230896#step:5:236

/opt/warehouse/lib/python3.12/site-packages/coverage/html.py:123: CoverageWarning: No contexts were measured
  self.coverage._warn("No contexts were measured")

We measure contexts here:

dynamic_context = "test_function"

This provides visual indicators in the HTML report to show which test functions are hitting a given line of code, making it easier to figure out which tests are calling what.

Is there anything on coverage.py tracking that issue, so we can leave ourselves a link to check in on it later on?

@DarkaMaul
Copy link
Contributor Author

Is there anything on coverage.py tracking that issue, so we can leave ourselves a link to check in on it later on?

I think we should simply monitor coverage CHANGELOG to see when they are supported.

This PR can be either put on hold until coverage changes, or we can use the new setting for CI runs (with the possibility for interested developers to use it locally too).

@miketheman
Copy link
Member

This PR can be either put on hold until coverage changes, or we can use the new setting for CI runs (with the possibility for interested developers to use it locally too).

I think we'd likely benefit from the speedups where possible.

Can you provide a hook to allow the developer to pass along a flag to revert the behavior? I don't think the current patch allows setting the envvar that passes to docker compose command in the Makefile, so giving the end user some pay of passing down that the COVERAGE_CORE should revert to to ctrace monitor would be good to have.

@miketheman miketheman merged commit 465079f into pypi:main Sep 5, 2024
18 checks passed
@facutuesca facutuesca deleted the dm/test-coverage-sysmon branch September 5, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer experience Anything that improves the experience for Warehouse devs testing Test infrastructure and individual tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants