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

Always build PGO using RUSTFLAGS #739

Merged
merged 2 commits into from
Jul 4, 2023
Merged

Conversation

messense
Copy link
Contributor

@messense messense commented Jul 4, 2023

Change Summary

There are many ways to pass flags to rustc:

  • cargo rustc, which only affects your crate and not its dependencies.
  • RUSTFLAGS environment variable, which affects dependencies as well.

See https://stackoverflow.com/a/38040431

In this case I think RUSTFLAGS is a better choice.

Related issue number

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

There are many ways to pass flags to rustc:

* `cargo rustc`, which only affects your crate and not its dependencies.
* `RUSTFLAGS` environment variable, which affects dependencies as well.

See https://stackoverflow.com/a/38040431

In this case I think `RUSTFLAGS` is a better choice.

- name: merge pgo data
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
run: rustup run stable llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Odd, worked for me locally on a Linux server.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah llvm-profdata is in an unusual bin directory (see the way I figure it out just above). The rustup team might have knowledge of why that worked (and the best practices to add it to path).

Copy link
Contributor

Choose a reason for hiding this comment

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 4, 2023

CodSpeed Performance Report

Merging #739 will not alter performances

Comparing messense:pgo-rustflags (aac3354) with main (5c696e5)

Summary

✅ 126 untouched benchmarks

Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks!

@messense what do you think of adding PGO support directly into either maturin or maturin-action?

I had to split out the build jobs in #678 because I need to pass different profiling data to each python build. In theory I think if maturin was given a command it could run to gather PGO data with each interpreter it should be able to:

  1. build all the initial wheels for profiling (current build
  2. for each interpreter in turn
    a. install the profiling wheel into the interpreter's environment
    b. run the PGO command to gather profiling data
    c. build the final optimized wheel

This might add quite a lot of complexity, so it might be better to keep this out of maturin and just add to maturin-action.

The upside would be that it would become much easier for other projects to also use PGO, and also I think an integrated action could reuse Rust build products better than I do with these builds.

@messense
Copy link
Contributor Author

messense commented Jul 4, 2023

what do you think of adding PGO support directly into either maturin or maturin-action?

I'm in favor of adding PGO support to one of them.

This might add quite a lot of complexity, so it might be better to keep this out of maturin and just add to maturin-action.

IMO the upside of adding it in maturin would be that it doesn't require GitHub Actions.

@davidhewitt davidhewitt merged commit d08d269 into pydantic:main Jul 4, 2023
@messense messense deleted the pgo-rustflags branch July 4, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants