Skip to content

📦 Make release builds compile very optimized#1586

Merged
webknjaz merged 3 commits intoaio-libs:masterfrom
webknjaz:packaging/optimized-release-n-comprehensive-debug
Oct 28, 2025
Merged

📦 Make release builds compile very optimized#1586
webknjaz merged 3 commits intoaio-libs:masterfrom
webknjaz:packaging/optimized-release-n-comprehensive-debug

Conversation

@webknjaz
Copy link
Member

@webknjaz webknjaz commented Oct 26, 2025

This patch improves the in-tree build backend to allow the end-users append CFLAGS and LDFLAGS by setting respecitve environment variables.

It additionally sets up default compiler flags to perform build with maximum optimization in release mode. And when line tracing is requested, the compiler and linker flags are configured to include as much information as possible for debugging and coverage tracking.

As a result, the C-extensions published to PyPI are going to be small while their development/testing environment variants will be big.

Are there changes in behavior for the user?

yarl's footprint is smaller, and it should run faster.

Checklist

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes yarl's C-extension builds by introducing build mode differentiation and allowing user-defined compiler flags. In release mode, extensions are compiled with maximum optimization and minimal debug information for smaller binaries and better performance. In debug mode (when line tracing is requested), comprehensive debugging symbols and coverage instrumentation are included.

  • Implements conditional compiler flags based on build mode (debug vs release)
  • Enables user override of CFLAGS and LDFLAGS through environment variables
  • Adds visual feedback showing which build mode is active

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packaging/pep517_backend/_cython_configuration.py Implements three-tier flag priority system and mode-specific optimization flags
packaging/pep517_backend/_backend.py Adds console output to display current build mode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Oct 26, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.57%. Comparing base (8f2b854) to head (cbe5b55).
⚠️ Report is 33 commits behind head on master.

Files with missing lines Patch % Lines
packaging/pep517_backend/_cython_configuration.py 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1586      +/-   ##
==========================================
- Coverage   99.60%   99.57%   -0.04%     
==========================================
  Files          29       29              
  Lines        5835     5853      +18     
  Branches      266      266              
==========================================
+ Hits         5812     5828      +16     
- Misses         19       21       +2     
  Partials        4        4              
Flag Coverage Δ
CI-GHA 99.57% <90.90%> (-0.04%) ⬇️
MyPy 97.94% <90.90%> (-0.03%) ⬇️
OS-Linux 99.80% <ø> (ø)
OS-Windows 99.48% <ø> (ø)
OS-macOS 99.68% <ø> (ø)
Py-3.10.11 99.45% <ø> (ø)
Py-3.10.18 99.70% <ø> (ø)
Py-3.11.13 99.70% <ø> (ø)
Py-3.11.9 99.45% <ø> (ø)
Py-3.12.10 99.45% <ø> (ø)
Py-3.12.11 99.70% <ø> (ø)
Py-3.13.7 99.75% <ø> (ø)
Py-3.13.9 99.65% <ø> (ø)
Py-3.13.9t 99.75% <ø> (ø)
Py-3.14.0 99.75% <ø> (ø)
Py-3.14.0t 99.75% <ø> (ø)
Py-3.9.13 99.41% <ø> (ø)
Py-3.9.23 99.65% <ø> (ø)
Py-pypy3.10.16-7.3.19 99.36% <ø> (ø)
Py-pypy3.9.19-7.3.16 99.33% <ø> (ø)
VM-macos-latest 99.68% <ø> (ø)
VM-ubuntu-latest 99.80% <ø> (ø)
VM-windows-latest 99.48% <ø> (ø)
pytest 99.80% <ø> (ø)

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.

@webknjaz webknjaz force-pushed the packaging/optimized-release-n-comprehensive-debug branch from b321d3e to 101826c Compare October 26, 2025 00:10
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 27, 2025

CodSpeed Performance Report

Merging #1586 will not alter performance

Comparing webknjaz:packaging/optimized-release-n-comprehensive-debug (cbe5b55) with master (075a535)1

Summary

✅ 101 untouched

Footnotes

  1. No successful run was found on master (cbe5b55) during the generation of this report, so 075a535 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

This patch improves the in-tree build backend to allow the end-users
append `CFLAGS` and `LDFLAGS` by setting respecitve environment
variables.

It additionally sets up default compiler flags to perform build with
maximum optimization in release mode. And when line tracing is
requested, the compiler and linker flags are configured to include as
much information as possible for debugging and coverage tracking.

As a result, the C-extensions published to PyPI are going to be small
while their development/testing environment variants will be big.
It appears that GCC supports them but Clang does not.
@webknjaz webknjaz force-pushed the packaging/optimized-release-n-comprehensive-debug branch from 3776944 to b96edd2 Compare October 28, 2025 14:35
@webknjaz
Copy link
Member Author

Alright.. Looks like it's time to compose a change note, now that the metrics are roughly what we expected.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 28, 2025
@webknjaz webknjaz merged commit ee03bb7 into aio-libs:master Oct 28, 2025
13 checks passed
webknjaz added a commit that referenced this pull request Oct 30, 2025
@rossburton
Copy link

To ensure it's here too: this breaks ~all Linux distributions where we want to build moderately optimised binaries with debug symbols, and split the symbols out ourselves. I filed #1592 with further details.

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 enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants