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

Add a benchmark for exhaustive_patterns #801

Merged

Conversation

Nadrieril
Copy link
Member

@Nadrieril Nadrieril commented Nov 26, 2020

The exhaustive_patterns feature was measured to cause significant perf degradation. I minimized the perf regression into this new benchmark, which I hope will be useful when hacking on match checking. I named it after exhaustive_patterns because I optimized for that (i.e. large nested structs and enums).
This benchmark gains 30% on check-full when the exhaustive_patterns feature is disabled.
Ping #792 and rust-lang/rust#51085.

@Nadrieril Nadrieril force-pushed the stress-exhaustive-patterns branch from b85fbec to 30ba044 Compare November 26, 2020 05:03
@Nadrieril
Copy link
Member Author

I don't know what's wrong with the failing CI test. I keep scrolling down without reaching the bottom of the logs

@Mark-Simulacrum
Copy link
Member

Yeah, CI logs are a bit opaque. Looks like you're missing a Cargo.lock in the newly added test?

2020-11-26T05:12:18.8310094Z Preparing match-stress-exhaustive_patterns
2020-11-26T05:12:18.8343075Z [2020-11-26T05:12:18Z INFO  collector::execute] run_rustc with incremental=false, build_kind=Opt, run_kind=None, patch=None
2020-11-26T05:12:18.8457896Z error: a Cargo.lock must exist for this command
2020-11-26T05:12:18.8465325Z Running match-stress-exhaustive_patterns: Opt + [Full, IncrFull, IncrUnchanged, IncrPatched]
2020-11-26T05:12:18.8467236Z [2020-11-26T05:12:18Z DEBUG collector::execute] Benchmark iteration 1/1
2020-11-26T05:12:18.8492777Z [2020-11-26T05:12:18Z INFO  collector::execute] run_rustc with incremental=false, build_kind=Opt, run_kind=Some(Full), patch=None
2020-11-26T05:12:18.8602535Z error: a Cargo.lock must exist for this command
2020-11-26T05:12:18.8619349Z collector error: Failed to benchmark 'match-stress-exhaustive_patterns', recorded: failed to obtain pkgid in '"/tmp/.tmpaxCyjg"'

@Mark-Simulacrum
Copy link
Member

This also needs to update the README in collector/benchmarks to note the newly added test (you can see some existing descriptions there).

@Mark-Simulacrum
Copy link
Member

I also noted that this doesn't seem to pull in the syn license files, but we should be careful to do so -- I think the easiest thing which should be correct is to just duplicate the license files as is into the directory.

@Mark-Simulacrum Mark-Simulacrum merged commit e28471d into rust-lang:master Nov 29, 2020
@Mark-Simulacrum
Copy link
Member

Thanks! This should automatically deploy on the next run or two.

@Nadrieril Nadrieril deleted the stress-exhaustive-patterns branch November 29, 2020 08:56
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 12, 2021
Turn type inhabitedness into a query to fix `exhaustive_patterns` perf

We measured in rust-lang#79394 that enabling the [`exhaustive_patterns` feature](rust-lang#51085) causes significant perf degradation. It was conjectured that the culprit is type inhabitedness checking, and [I hypothesized](rust-lang#79394 (comment)) that turning this computation into a query would solve most of the problem.

This PR turns `tcx.is_ty_uninhabited_from` into a query, and I measured a 25% perf gain on the benchmark that stress-tests `exhaustiveness_patterns`. This more than compensates for the 30% perf hit I measured [when creating it](rust-lang/rustc-perf#801). We'll have to measure enabling the feature again, but I suspect this fixes the perf regression entirely.
I'd like a perf run on this PR obviously.
I made small atomic commits to help reviewing. The first one is just me discovering the "revisions" feature of the testing framework.

I believe there's a push to move things out of `rustc_middle` because it's huge. I guess `inhabitedness/mod.rs` could be moved out, but it's quite small. `DefIdForest` might be movable somewhere too. I don't know what the policy is for that.

Ping `@camelid` since you were interested in following along
`@rustbot` modify labels: +A-exhaustiveness-checking
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