-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
x64: add x64 encoding benchmarks #2888
Conversation
@cfallin, I went ahead and disabled the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! If you want to look into it, I think there's a way to feature-gate the whole bench on x86 being compiled in, but since it's not built by default (needs a specific cargo bench
invocation) I think it's not the end of the world if that doesn't work either.
In order to benchmark the encoding code with criterion, the functions and structures must be public. Moving this code to its own module (instead of keeping as a submodule to `inst`), allows `inst` to remain private. This avoids having to expose and document (or ignore documenting) the numerous instruction variants in `inst` while allowing access to the encoding code. This commit changes no functionality.
In order to benchmark portions of the x64 module, this change makes it a public module of cranelift-codegen.
This change adds a criterion-enabled benchmark, x64-evex-encoding, to compare the performance of the builder pattern used to encode EVEX instructions in the new x64 backend against the function pattern used to encode EVEX instructions in the legacy x86 backend. At face value, the results imply that the builder pattern is faster, but no efforts were made to analyze and optimize these approaches further.
Until japaric/cast.rs#26 is resolved, the `cast` crate will pull in older versions of the `rustc_version`, `semver`, and `semver-parser` crates. `cast` is a build dependency of `criterion` which is used for benchmarking and is itself a dev dependency, not a normal dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This is a follow-up to #2819 to add a benchmark comparing the different encoding approaches (builder vs function) used to encode EVEX instructions. The measurements I observed indicate that the builder pattern is faster, as noted in #2819. The more interesting improvement of this PR is to show how to measure parts of the
cranelift-codegen
crate. To do so withcriterion
, I had to make some of the x64 module public:encoding
module out ofx64::inst
so thatx64::inst
does not have to become publicx64
module itself public