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

Build Python polars wheels with PGO #9702

Open
messense opened this issue Jul 4, 2023 · 12 comments
Open

Build Python polars wheels with PGO #9702

messense opened this issue Jul 4, 2023 · 12 comments
Labels
enhancement New feature or an improvement of an existing feature

Comments

@messense
Copy link
Contributor

messense commented Jul 4, 2023

Problem description

It seems that PGO is a success for pydantic-core, I wonder whether it will speedup py-polars.

@messense messense added the enhancement New feature or an improvement of an existing feature label Jul 4, 2023
@ritchie46
Copy link
Member

Yes, I'd be very interested in that. I think including the db-benchmark and the tpch benchmark code in the guided data seem to me to be interesting candidates.

Tests would be easiest. Not any experience with setting it up though, so any help on this is appreciated.

@messense
Copy link
Contributor Author

messense commented Jul 5, 2023

@ritchie46 Is there any easy way to compare two benchmark results? I'd like to confirm that it actually improves performance before putting too much effort.

@ritchie46
Copy link
Member

The easiest start are the TPCH benchmarks: https://github.com/pola-rs/tpch/tree/main/polars_queries

The repo has a Makefile that creates the dataset. Running this provides a timing table and some plot utils. Now that I think of it, that's also good PGO input.

@zamazan4ik
Copy link

I think you also could be interested in my recent benchmark regarding PGO to different kinds of software (including a lot of databases and database libraries (like RocksDB)) - https://github.com/zamazan4ik/awesome-pgo .

@jmakov
Copy link

jmakov commented Aug 19, 2023

From some of the blog posts it looks like +15% can be done. That's the difference a CPU makes from one generation to another.

@FilipAndersson245
Copy link

Any update on this? PGO is a very interesting way to improve performance with the only cost is deployment and build complexity.
I can recommend looking at https://github.com/Kobzol/cargo-pgo for inspiration on how to run it.

@alonme
Copy link
Contributor

alonme commented Sep 21, 2024

I started taking a look at that today.

It seemed that using the flow documented in https://doc.rust-lang.org/rustc/profile-guided-optimization.html - and when benchmarking the PGO'd version after that - i didn't any change in performance.

I suspect that the issue is that only the py-polars crate was actually compiled to generate the profiling data and then optimized.

Currently trying to make it work on all the crates

(Note - I use rosetta2, However i don't think that should be a problem or a reason for the PGO not to make an affect)

@FilipAndersson245
Copy link

I have only used Kobzols Cargo-pgo tool so i have less experience with the raw pgo scripts. @zamazan4ik the go to guy with everything pgo.

@alonme
Copy link
Contributor

alonme commented Sep 21, 2024

After Compiling with global flags e.g. export RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data and then export RUSTFLAGS=-Cprofile-use=/tmp/pgo-data/merged.profdata errors when compiling the second one with

!"CG Profile"
rustc-LLVM ERROR: Broken module found, compilation aborted!
error: could not compile `py-polars` (lib)

which is referenced in the following issues:
rust-lang/rust#115344
rust-lang/rust#117220

I will try to check if a different LTO setting will make it compile, and check the effect

@alonme
Copy link
Contributor

alonme commented Sep 21, 2024

lto = "thin" compiles successfully 👍

@alonme
Copy link
Contributor

alonme commented Mar 1, 2025

After Compiling with global flags e.g. export RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data and then export RUSTFLAGS=-Cprofile-use=/tmp/pgo-data/merged.profdata errors when compiling the second one with

!"CG Profile"
rustc-LLVM ERROR: Broken module found, compilation aborted!
error: could not compile `py-polars` (lib)

which is referenced in the following issues: rust-lang/rust#115344 rust-lang/rust#117220

I will try to check if a different LTO setting will make it compile, and check the effect

these rust issues have been resolved - would probably be a good idea to try again

@FilipAndersson245
Copy link

FilipAndersson245 commented Mar 9, 2025

@alonme did you manage to build with lot and pgo?, I know you looked into this earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

6 participants