x64: add x64 encoding benchmarks#2888
Merged
Merged
Conversation
abrown
commented
May 10, 2021
Member
Author
|
@cfallin, I went ahead and disabled the |
cfallin
approved these changes
May 12, 2021
Member
cfallin
left a comment
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-codegencrate. To do so withcriterion, I had to make some of the x64 module public:encodingmodule out ofx64::instso thatx64::instdoes not have to become publicx64module itself public