leanprover / lean4

Lean 4 programming language and theorem prover
https://lean-lang.org
Apache License 2.0
3.82k stars 325 forks source link

perf: issue at `binop%` and `binrel%` elaborators #4085

Closed leodemoura closed 1 week ago

leodemoura commented 1 week ago

This issue was affecting several Mathlib files.

@mattrobball Found where the [nonassignable]s were coming from. Thanks for helping to diagnose this performance issue.

leanprover-community-mathlib4-bot commented 1 week ago

Mathlib CI status (docs):

mattrobball commented 1 week ago

At leanprover-community/mathlib4#12718, I benchmarked a working mathlib with a v4.8.0-rc1 with this commit cherry picked on top.

Overall there is a -400B in instructions driven mainly by one file which was -800B. The issue there was the new CoeT synthesis attempts in Lean.Elab.Term.Op.hasCoe.

semorrison commented 1 week ago

The new slow-downs are pretty severe in Mathlib.AlgebraicGeometry.Restrict.

semorrison commented 1 week ago

I got different speed center results from https://github.com/leanprover-community/mathlib4/pull/12719 than @mattrobball got from https://github.com/leanprover-community/mathlib4/pull/12718; mine are worse, with an overall +500B instructions... The difference probably comes down to exactly where they converge with the master line in Mathlib; we're comparing against different base commits.

mattrobball commented 1 week ago

It's universes triggering the expensive CoeT's.

semorrison commented 1 week ago

Closing in favour of #4092.