9

Github Turn type inhabitedness into a query to fix `exhaustive_patterns` perf by...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/79670
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Contributor

Nadrieril commented on Dec 4, 2020

edited

We measured in #79394 that enabling the exhaustive_patterns feature causes significant perf degradation. It was conjectured that the culprit is type inhabitedness checking, and I hypothesized 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. 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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK