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

perf: do not inhibit caching of default-level match reduction #2612

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

Kha
Copy link
Member

@Kha Kha commented Oct 2, 2023

Resolves #2564.

Note that this does not resolve the same issue at reducible level, e.g. during simp. This would require adding a new cache (@leodemoura like I thought we would already need here but it turned out to be much more simple). But this should warrant separate motivation. In most non-trivial match cases like in #2564, it seems we do match on non-reducible functions.

@Kha
Copy link
Member Author

Kha commented Oct 2, 2023

(Speedup is ~100x for the specific example but as the old behavior is exponential, that's just one data point)

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 2, 2023
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 2, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 2, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Oct 2, 2023

@Kha
Copy link
Member Author

Kha commented Oct 2, 2023

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 62f5ae7.
There were significant changes against commit 06e0577:

  Benchmark          Metric          Change
  ==================================================
- lake build clean   branch-misses     1.5% (13.7 σ)
- stdlib             type checking     1.1% (10.1 σ)
- stdlib             wall-clock        1.2% (10.6 σ)

@Kha
Copy link
Member Author

Kha commented Oct 2, 2023

Unclear if statistically significant?
!bench

@Kha
Copy link
Member Author

Kha commented Oct 2, 2023

mathlib4 comparison with master: http://speed.lean-fro.org/mathlib4/compare/e7b27246-a3e6-496a-b552-ff4b45c7236e/to/6cc64386-e156-4029-9d32-5f95588c85c1?hash1=f1a26d74c6f24f344bb4656785c9c24958df74da. No significant change overall, which makes sense given the relative lack of match in mathlib, but some significant improvements in a few specific files.

@Kha
Copy link
Member Author

Kha commented Oct 4, 2023

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 62f5ae7.
There were significant changes against commit 06e0577:

  Benchmark          Metric          Change
  ==================================================
- lake build clean   branch-misses     1.5% (13.7 σ)
- stdlib             type checking     1.1% (10.1 σ)
- stdlib             wall-clock        1.2% (10.6 σ)

leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 4, 2023
semorrison added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 4, 2023
@collares
Copy link
Contributor

collares commented Oct 5, 2023

This PR also fixes a timeout in the following example:

def dedup {α} [DecidableEq α] : List α → List α :=
List.foldr (fun x IH => if IH.all (· ≠ x) then x :: IH else IH) []

example : dedup (List.replicate 11 0) = [0] := rfl

@leodemoura leodemoura merged commit 00e981e into leanprover:master Oct 9, 2023
15 checks passed
@Kha Kha deleted the whnf-matcher branch October 13, 2023 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

match reduction is slow
5 participants