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

bench, pgo, release profile #13

Closed
mibere opened this issue Jun 29, 2024 · 3 comments
Closed

bench, pgo, release profile #13

mibere opened this issue Jun 29, 2024 · 3 comments

Comments

@mibere
Copy link

mibere commented Jun 29, 2024

Hi there,

are there plans to implement a 'bench' command, that can be used for PGO during compilation and to compare different compile settings?

And, is there a benefit to set a release profile in Cargo.toml?

[profile.release]
...

with settings like opt-level, lto, panic, strip

Here we read

If you want to maximize runtime speed, consider all of the following: codegen-units = 1, lto = "fat", an alternative allocator, and panic = "abort".

Example

[profile.release]
codegen-units = 1
opt-level = 3
lto = = "fat"
panic = "abort"
strip = true

Thanks for your engine, your time and work. Keep on!

@mhonert
Copy link
Owner

mhonert commented Jun 30, 2024

Hi,

thanks for the suggestions.
A while ago, I compared the performance impact of several options and also had a look at PGO.
Back then, my conclusion was to leave most parameters to the defaults, but only set "codegen-units = 1" in the Cargo.toml (opt-level 3 is already the default for release builds).
It increased compile times significantly, but also produced the most performant code (at least on the 3 CPUs I tested).

But in the meantime, new Rust and LLVM versions have been released and it might make sense to check the best parameters again.
I did a short test today with the default setting for codegen-units (which is 16 for release builds) and with lto set to "thin" and it was slightly faster.

I will do some more comparisons and also implement a bench command for the next release.

Best regards.

@mibere
Copy link
Author

mibere commented Jun 30, 2024

For the sake of completeness, just found the default settings for the release profile.

In regard to performance, what I have read most often for a release is codegen-units = 1 + panic = "abort" + enabled LTO.

I was able to successfully compile the engine with MSYS2 (Rust 1.79.0, Clang 18.1.8). Sadly, no PGO is possible with it. Seems for that you have to install Rust natively and VS C++ Build tools with Clang.

@mhonert
Copy link
Owner

mhonert commented Aug 17, 2024

I just released v8.0.0, which added the "bench" command.

@mhonert mhonert closed this as completed Sep 27, 2024
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

No branches or pull requests

2 participants