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

Runtime benchmark codegen diff #1697

Merged
merged 3 commits into from
Aug 14, 2023
Merged

Runtime benchmark codegen diff #1697

merged 3 commits into from
Aug 14, 2023

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Aug 12, 2023

This PR adds a new command to collector, called codegen_diff. It takes as input the name of a single runtime benchmark group, the type of codegen you are interested in (assembly, assembly interleraved with Rust source, LLVM IR or MIR) and two versions of the compiler. It then uses the cargo-show-asm tool to compute the codegen and diff it between the two compiler versions.

The diff is computed separately for each symbol (function) found in the benchmark crate. We therefore have to match the same function between two rustc versions (toolchains) by its symbol name. By default, cargo asm doesn't include hashes in the symbol names, which helps making sure that the name will stay the same, but it also means that a different version of the same function (e.g. one monomorphized with a different generic argument) will get matched between two toolchains. There is a cargo asm flag called --full-name which includes the hashes in the symbol names, which would resolve this issue. However, there is a problem with that - different versions of the compiler produce different hashes, and this doesn't seem to be easily fixable. Therefore, I don't include the hashes in the symbol names, and I also opted in to the v0 mangling scheme, as it seems to me that with it more functions are matched even without the hashes.

The diff for each function is then printed to stdout, with colors if the output is a terminal. Eventually we might want to display some small HTML page so that the diff is easier to understand (?).

collector/README.md Outdated Show resolved Hide resolved
collector/src/bin/collector.rs Outdated Show resolved Hide resolved
collector/src/bin/collector.rs Outdated Show resolved Hide resolved
collector/src/codegen.rs Outdated Show resolved Hide resolved
collector/src/codegen.rs Outdated Show resolved Hide resolved
collector/src/codegen.rs Show resolved Hide resolved
collector/src/codegen.rs Outdated Show resolved Hide resolved
@Kobzol
Copy link
Contributor Author

Kobzol commented Aug 14, 2023

Thanks!

@Kobzol Kobzol enabled auto-merge August 14, 2023 10:36
@Kobzol Kobzol merged commit 2f20131 into rust-lang:master Aug 14, 2023
9 checks passed
@Kobzol Kobzol deleted the codegen-diff branch August 17, 2023 10:01
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