gnzlbg / cargo-asm

cargo subcommand showing the assembly or llvm-ir generated for Rust code
https://github.com/gnzlbg/cargo-asm
Other
1.18k stars 36 forks source link

Change in release build performance after running cargo asm #239

Open space-alien opened 3 years ago

space-alien commented 3 years ago

After running cargo asm, I am noticing a very significant performance drop when running my release build, which I do not understand.

Given this, I wonder whether cargo asm is building my project in a different way to the normal release build. My primary concen is that the asm being produced by cargo asm may not be the same as the normal release build, since I imagine that the performance drop would indicate a significant difference in the compiled output.

Toolchain info: nightly-x86_64-pc-windows-msvc (default) rustc 1.56.0-nightly (d3e2578c3 2021-08-21)

My process: (1) Regular release build: cargo build --release target/release/myproject.exe -> Normal (i.e. fast) performance

(2) Run cargo asm: cargo asm target/release/myproject.exe -> Performance drops substantially (in my case, the normal release build is 50% faster)

space-alien commented 3 years ago

Perhaps the culprit is codegen-units=1. When I set this on my release profile, I am able to reproduce the performance drop.

FedericoStra commented 2 years ago

Perhaps the culprit is codegen-units=1.

I have experienced a similar situation where the assembly code printed by asm does not coincide with the one actually built by cargo build --release, but they do if i use RUSTFLAGS="-Ccodegen-units=1" cargo build --release.

Unfortunately this project seems both broken and dead...