leanprover-community / leanprover-community/mathlib4
Improving the performance of typeclass inference
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 4.2k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the performance of typeclass inference in mathlib is still unsatisfactory. This is often because the DFS process enters a node that cannot reach the goal and does a lot of useless searching.
One solution is to adjust the instance priority so that frequent targets are reached more quickly. This can significantly improve performance overall. See previous attempts in #7873 #13852 #13690.
Another solution is to use more mixins to avoid oversized hierarchies, but be careful that this may cause additional searching with the current synthesis algorithm. See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Ways.20to.20speed.20up.20Mathlib/near/468146934.
The following are relevant PRs or experiments.
Adjusting typeclass search paths:
- (needs to be split) #7873
- #14712
- #18464
-
#18468migrated to mixins - #18470
- #18472
- #18474
Adding shortcuts:
- #13852
Slow multi-parameter class instances:
- #13690
- #16607
- #16646
- #16486
- #17410
- #17411
- #17529
- #17530
- #17675
Decouple hierarchies / Migrate to mixin typeclasses:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the prior attempts and experiments linked in the issue, especially the listed pull requests and the Zulip discussion. Identify a bounded typeclass-inference optimization before making changes; done should be demonstrated by improved performance without introducing the cautions described in the issue.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100