perf: Group match rows by head constructor when specializing [match-stress -41%] - #87
Draft
xmakro wants to merge 1 commit into
Draft
perf: Group match rows by head constructor when specializing [match-stress -41%]#87xmakro wants to merge 1 commit into
xmakro wants to merge 1 commit into
Conversation
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.
Exhaustiveness checking specializes the pattern matrix with each constructor of a column in
turn, and each specialization walks every row of the matrix. A match with one arm per variant of
an enum with V variants therefore does V passes over V rows. On
match-stress, which is mostlyPartialEqderives on large enums,compute_exhaustiveness_and_usefulnessis 42% of theinstructions of the whole compile.
Group the rows of a column by the discriminant of their head constructor once, so that
specializing with a constructor only looks at the rows whose head has the same discriminant plus
the rows whose head decides coverage by something other than equality (wildcards, ranges, slices,
opaque constants). Both lists are kept in row order and merged, so rows are still visited in
their original order, and
is_covered_bystill decides. The index is only built when a columnhas more than one constructor and the matrix has at least 8 rows.
Measured on 12 crates, Check and Debug,
instructions:u, isolated against the same base:The other 22 cells (bitmaps, clap_derive, cranelift-codegen, hyper, image, many-assoc-items,
nalgebra, ripgrep, serde, syn, typenum) are all within 0.14%, geomean -4.30%.
The full
tests/uisuite passes (21309 tests), as dotests/incremental(178 tests) and therustc_pattern_analysisunit tests.