Skip to content

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Jun 9, 2025

This PR modifies the build backend to dynamically enable Cython line tracing only when explicitly requested via the with-cython-tracing=true config setting. Previously, having linetrace = "True" in pyproject.toml was causing build issues for users (aio-libs/frozenlist#658) and makes our production wheels almost half as fast.

Now, line tracing is opt-in:

  • Regular builds: pip install . (no line tracing)
  • Tracing builds: pip install . --config-setting=with-cython-tracing=true (enables line tracing)

When tracing is requested, the build backend automatically adds the linetrace=True and profile=True Cython directives and sets the appropriate C compiler flags.

  • Regular users will no longer encounter build issues related to line tracing being enabled by default
  • Developers who need line tracing must now explicitly enable it using --config-setting=with-cython-tracing=true
  • The PROPCACHE_CYTHON_TRACING environment variable can also be used as an alternative to the config setting
  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

What do these changes do?

Are there changes in behavior for the user?

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

bdraco added 2 commits June 9, 2025 16:10
This PR modifies the build backend to dynamically enable Cython line tracing only when explicitly requested via the `with-cython-tracing=true` config setting. Previously, having `linetrace = "True"` in pyproject.toml was causing build issues for users (aio-libs/frozenlist#658) and makes our production wheels almost half as fast.

Now, line tracing is opt-in:
- Regular builds: `pip install .` (no line tracing)
- Tracing builds: `pip install . --config-setting=with-cython-tracing=true` (enables line tracing)

When tracing is requested, the build backend automatically adds the `linetrace=True` and `profile=True` Cython directives and sets the appropriate C compiler flags.

<!-- Outline any notable behaviour for the end users. -->

- Regular users will no longer encounter build issues related to line tracing being enabled by default
- Developers who need line tracing must now explicitly enable it using `--config-setting=with-cython-tracing=true`
- The `YARL_CYTHON_TRACING` environment variable can also be used as an alternative to the config setting

<!-- Are there any issues opened that will be resolved by merging this change? -->
<!-- Remember to prefix with 'Fixes' if it should close the issue (e.g. 'Fixes #123'). -->

- [x] I think the code is well written
- [ ] Unit tests for the changes exist
- [ ] Documentation reflects the changes
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jun 9, 2025
@bdraco bdraco marked this pull request as ready for review June 9, 2025 21:25
@bdraco bdraco enabled auto-merge (squash) June 9, 2025 21:25
Copy link

codspeed-hq bot commented Jun 9, 2025

CodSpeed Performance Report

Merging #118 will not alter performance

Comparing linetrace_fix (37ba8b9) with master (beb5475)

Summary

✅ 4 untouched benchmarks

Copy link

codecov bot commented Jun 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.64%. Comparing base (beb5475) to head (37ba8b9).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #118      +/-   ##
==========================================
- Coverage   97.72%   97.64%   -0.09%     
==========================================
  Files          18       17       -1     
  Lines         792      763      -29     
  Branches       41       41              
==========================================
- Hits          774      745      -29     
  Misses         10       10              
  Partials        8        8              
Flag Coverage Δ
CI-GHA 97.64% <100.00%> (-0.09%) ⬇️
MyPy 93.20% <100.00%> (+0.07%) ⬆️
OS-Linux 96.91% <ø> (-0.29%) ⬇️
OS-Windows 93.27% <ø> (ø)
OS-macOS 93.27% <ø> (-0.64%) ⬇️
Py-3.10.11 91.03% <ø> (-0.85%) ⬇️
Py-3.10.17 93.27% <ø> (-0.64%) ⬇️
Py-3.11.12 95.23% <ø> (-0.45%) ⬇️
Py-3.11.9 92.99% <ø> (-0.66%) ⬇️
Py-3.12.10 95.23% <ø> (-0.45%) ⬇️
Py-3.13.1 95.23% <ø> (ø)
Py-3.13.3 95.23% <ø> (-0.45%) ⬇️
Py-3.9.13 91.01% <ø> (-0.85%) ⬇️
Py-3.9.22 93.25% <ø> (-0.64%) ⬇️
Py-pypy7.3.16 92.97% <ø> (ø)
Py-pypy7.3.19 92.99% <ø> (ø)
VM-macos-latest 93.27% <ø> (-0.64%) ⬇️
VM-ubuntu-latest 96.91% <ø> (-0.29%) ⬇️
VM-windows-latest 93.27% <ø> (ø)
pytest 96.91% <ø> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco merged commit f0a7eac into master Jun 9, 2025
50 of 51 checks passed
@bdraco bdraco deleted the linetrace_fix branch June 9, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant