mathlib4 icon indicating copy to clipboard operation
mathlib4 copied to clipboard

chore: remove redundant covariance instances, add priority

Open astrainfinita opened this issue 1 year ago • 7 comments
trafficstars

I noticed that the following code is surprisingly slow.

import Mathlib

count_heartbeats in
example {n : ℕ} : CovariantClass (Fin (n + 1)) (Fin (n + 1)) (· + ·) (· < ·) := by
  try infer_instance
  sorry

This PR removed some redundant instances. The heartbeats have dropped from 19118 to 11450 (still too slow). Lean4 still seems to make some redundant attempts. See also https://github.com/leanprover-community/mathlib4/issues/6646#issuecomment-1691792488.


Open in Gitpod

astrainfinita avatar Dec 24 '23 06:12 astrainfinita

!bench

astrainfinita avatar Dec 25 '23 03:12 astrainfinita

Here are the benchmark results for commit a6e645f7c7c8d8c2f2f0b7facb405c6a7c8f1d20. There were significant changes against commit e9fb5b31bb918376a758dec1ff49931062deb8f4:

  Benchmark                                  Metric         Change
  ================================================================
- ~Mathlib.CategoryTheory.ComposableArrows   instructions     6.1%

leanprover-bot avatar Dec 25 '23 03:12 leanprover-bot

!bench

astrainfinita avatar Dec 25 '23 21:12 astrainfinita

Here are the benchmark results for commit 1a749e0ff829652853aecae457336ffbeee6cb36. There were significant changes against commit e9fb5b31bb918376a758dec1ff49931062deb8f4:

  Benchmark                                  Metric         Change
  ================================================================
- ~Mathlib.CategoryTheory.ComposableArrows   instructions     5.3%

leanprover-bot avatar Dec 25 '23 21:12 leanprover-bot

I'm changing it to awaiting-author because it's marked as a draft PR and as a WIP. If it's ready for review, then please change it from draft to a normal PR and adjust the labels.

urkud avatar Jan 21 '24 02:01 urkud

!bench

astrainfinita avatar May 12 '24 04:05 astrainfinita

Here are the benchmark results for commit 45d4cccc28894bf4490178a81ffd4678a0ff11a7. There were no significant changes against commit 3502115bbf882ed91452052c41607a3e5139e1e1.

leanprover-bot avatar May 12 '24 04:05 leanprover-bot