[Merged by Bors] - perf: remove overspecified fields#6965
[Merged by Bors] - perf: remove overspecified fields#6965mattrobball wants to merge 22 commits intomasterfrom
Conversation
|
You checked in an |
|
No. I wasn’t being careful because none of this really works. It is more for ease of communication at the moment. Eventually, there will be a real toolchain here with changes that will be benched. |
|
!bench |
|
Here are the benchmark results for commit 27719fb. Benchmark Metric Change
============================================================================
+ build maxrss -7.7%
- ~Mathlib.Algebra.Category.ModuleCat.EpiMono instructions 8.6%
- ~Mathlib.Algebra.Category.ModuleCat.Subobject instructions 5.5%
+ ~Mathlib.Algebra.Category.Ring.Adjunctions instructions -7.6%
+ ~Mathlib.Algebra.DirectSum.Ring instructions -24.2%
+ ~Mathlib.Algebra.EuclideanDomain.Instances instructions -17.1%
+ ~Mathlib.Algebra.FreeNonUnitalNonAssocAlgebra instructions -10.7%
+ ~Mathlib.Algebra.Group.TypeTags instructions -6.8%
+ ~Mathlib.Algebra.GroupRingAction.Subobjects instructions -6.0%
+ ~Mathlib.Algebra.Lie.Engel instructions -5.5%
+ ~Mathlib.Algebra.Lie.Matrix instructions -6.6%
+ ~Mathlib.Algebra.Lie.OfAssociative instructions -11.2%
+ ~Mathlib.Algebra.MonoidAlgebra.Basic instructions -9.2%
+ ~Mathlib.Algebra.MonoidAlgebra.Grading instructions -18.9%
+ ~Mathlib.Algebra.Order.Pi instructions -14.6%
+ ~Mathlib.Algebra.Order.Ring.WithTop instructions -19.6%
+ ~Mathlib.Algebra.Ring.Defs instructions -6.0%
+ ~Mathlib.Algebra.Star.Module instructions -14.1%
+ ~Mathlib.Algebra.Symmetrized instructions -5.8%
+ ~Mathlib.AlgebraicGeometry.EllipticCurve.Point instructions -9.1%
+ ~Mathlib.Analysis.Calculus.IteratedDeriv instructions -5.0%
+ ~Mathlib.Analysis.NormedSpace.Completion instructions -6.6%
+ ~Mathlib.Analysis.NormedSpace.Dual instructions -33.9%
+ ~Mathlib.Analysis.NormedSpace.Multilinear instructions -6.0%
+ ~Mathlib.Data.MvPolynomial.Funext instructions -6.1%
+ ~Mathlib.Data.Polynomial.Monomial instructions -8.9%
+ ~Mathlib.FieldTheory.Cardinality instructions -54.6%
+ ~Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure instructions -16.6%
+ ~Mathlib.FieldTheory.MvPolynomial instructions -14.2%
+ ~Mathlib.FieldTheory.PolynomialGaloisGroup instructions -8.1%
+ ~Mathlib.FieldTheory.SplittingField.Construction instructions -22.1%
- ~Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional instructions 5.6%
- ~Mathlib.LinearAlgebra.AffineSpace.Restrict instructions 7.3%
+ ~Mathlib.LinearAlgebra.Charpoly.Basic instructions -5.8%
+ ~Mathlib.LinearAlgebra.DirectSum.Finsupp instructions -14.0%
- ~Mathlib.LinearAlgebra.DirectSum.TensorProduct instructions 11.5%
+ ~Mathlib.LinearAlgebra.FiniteDimensional instructions -10.4%
+ ~Mathlib.LinearAlgebra.FreeAlgebra instructions -6.7%
- ~Mathlib.LinearAlgebra.FreeModule.Finite.Rank instructions 6.5%
- ~Mathlib.LinearAlgebra.Isomorphisms instructions 40.7%
- ~Mathlib.LinearAlgebra.Matrix.Charpoly.Basic instructions 5.4%
+ ~Mathlib.LinearAlgebra.Matrix.Charpoly.Coeff instructions -6.5%
+ ~Mathlib.NumberTheory.LegendreSymbol.GaussSum instructions -7.9%
+ ~Mathlib.NumberTheory.NumberField.Norm instructions -5.7%
+ ~Mathlib.RepresentationTheory.Maschke instructions -6.0%
+ ~Mathlib.RingTheory.FinitePresentation instructions -26.8%
+ ~Mathlib.RingTheory.FreeCommRing instructions -9.5%
- ~Mathlib.RingTheory.MatrixAlgebra instructions 12.4%
+ ~Mathlib.RingTheory.MvPolynomial.Homogeneous instructions -5.8%
+ ~Mathlib.RingTheory.MvPolynomial.Ideal instructions -6.8%
+ ~Mathlib.RingTheory.Nullstellensatz instructions -22.5%
+ ~Mathlib.RingTheory.Polynomial.Basic instructions -5.9%
+ ~Mathlib.RingTheory.Polynomial.GaussLemma instructions -5.9%
- ~Mathlib.RingTheory.Polynomial.Vieta instructions 6.3%
+ ~Mathlib.RingTheory.RootsOfUnity.Minpoly instructions -35.2%
- ~Mathlib.RingTheory.SimpleModule instructions 24.2%
+ ~Mathlib.RingTheory.WittVector.Basic instructions -6.5%
+ ~Mathlib.RingTheory.WittVector.Defs instructions -9.2%
+ ~Mathlib.RingTheory.WittVector.Teichmuller instructions -15.1%
+ ~Mathlib.RingTheory.WittVector.WittPolynomial instructions -7.3% |
|
Looks like you checked in an |
again
|
I am not sure how it keeps happening... |
sgouezel
left a comment
There was a problem hiding this comment.
This is clearly a step in the right direction, opening the way to other improvements. Can you maybe explain in the PR description how you found those? (And in particular if you expect to have catched all of them, or if it was just a random selection)?
| instance instCommRing : CommRing (RatFunc K) := | ||
| { instCommMonoid K, instAddCommGroup K with | ||
| add := (· + ·) | ||
| zero := 0 |
There was a problem hiding this comment.
how come you still need the zero and the sub, while you have instAddCommGroup K above?
There was a problem hiding this comment.
This broke and I didn't push it.
I expanded. Please let me know how it reads. What I did was kinda hacky. The correct thing to do is to make a Lean.Linter which checks the overlaps for syntactic equality (up to some reasonable differences) and complains if so. Mario had some thoughts on this. |
|
!bench |
|
Here are the benchmark results for commit e3fe071. Benchmark Metric Change
=========================================================================================
+ lint wall-clock -8.0%
- ~Mathlib.Algebra.Category.ModuleCat.EpiMono instructions 13.9%
- ~Mathlib.Algebra.Category.ModuleCat.Images instructions 8.9%
- ~Mathlib.Algebra.Category.ModuleCat.Kernels instructions 5.6%
- ~Mathlib.Algebra.Category.ModuleCat.Subobject instructions 12.7%
+ ~Mathlib.Algebra.Category.Ring.Adjunctions instructions -7.6%
+ ~Mathlib.Algebra.DirectSum.Ring instructions -24.2%
+ ~Mathlib.Algebra.EuclideanDomain.Instances instructions -18.1%
+ ~Mathlib.Algebra.FreeNonUnitalNonAssocAlgebra instructions -10.8%
+ ~Mathlib.Algebra.Group.TypeTags instructions -7.0%
+ ~Mathlib.Algebra.GroupRingAction.Subobjects instructions -6.0%
- ~Mathlib.Algebra.Lie.Abelian instructions 17.2%
+ ~Mathlib.Algebra.Lie.Engel instructions -6.2%
+ ~Mathlib.Algebra.Lie.Free instructions -5.5%
+ ~Mathlib.Algebra.Lie.Matrix instructions -6.5%
+ ~Mathlib.Algebra.Lie.OfAssociative instructions -10.9%
- ~Mathlib.Algebra.Lie.Semisimple instructions 27.6%
- ~Mathlib.Algebra.Lie.Solvable instructions 10.4%
- ~Mathlib.Algebra.Lie.Submodule instructions 8.1%
- ~Mathlib.Algebra.Lie.TensorProduct instructions 12.4%
- ~Mathlib.Algebra.Lie.Weights instructions 20.9%
- ~Mathlib.Algebra.LinearRecurrence instructions 9.2%
- ~Mathlib.Algebra.Module.Zlattice instructions 18.2%
+ ~Mathlib.Algebra.MonoidAlgebra.Basic instructions -9.4%
+ ~Mathlib.Algebra.MonoidAlgebra.Grading instructions -19.6%
+ ~Mathlib.Algebra.Order.Pi instructions -14.7%
+ ~Mathlib.Algebra.Order.Ring.WithTop instructions -19.6%
+ ~Mathlib.Algebra.Ring.Defs instructions -6.6%
+ ~Mathlib.Algebra.Star.Module instructions -18.6%
+ ~Mathlib.Algebra.Symmetrized instructions -5.9%
+ ~Mathlib.AlgebraicGeometry.EllipticCurve.Point instructions -9.1%
+ ~Mathlib.Analysis.Calculus.IteratedDeriv instructions -5.0%
- ~Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho instructions 11.5%
- ~Mathlib.Analysis.InnerProductSpace.Projection instructions 14.2%
+ ~Mathlib.Analysis.NormedSpace.Completion instructions -6.6%
+ ~Mathlib.Analysis.NormedSpace.Dual instructions -33.9%
- ~Mathlib.CategoryTheory.Limits.FilteredColimitCommutesFiniteLimit instructions 8.8%
- ~Mathlib.CategoryTheory.Monad.Basic instructions 9.3%
- ~Mathlib.Data.Matrix.Rank instructions 21.9%
+ ~Mathlib.Data.MvPolynomial.Funext instructions -6.0%
+ ~Mathlib.Data.Polynomial.Laurent instructions -5.1%
+ ~Mathlib.Data.Polynomial.Monomial instructions -9.7%
+ ~Mathlib.FieldTheory.Cardinality instructions -54.6%
+ ~Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure instructions -16.7%
+ ~Mathlib.FieldTheory.MvPolynomial instructions -14.9%
+ ~Mathlib.FieldTheory.PolynomialGaloisGroup instructions -8.3%
+ ~Mathlib.FieldTheory.SplittingField.Construction instructions -19.5%
- ~Mathlib.Geometry.Euclidean.Circumcenter instructions 11.6%
- ~Mathlib.Geometry.Euclidean.Inversion.Calculus instructions 9.4%
- ~Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional instructions 24.1%
- ~Mathlib.LinearAlgebra.AffineSpace.Restrict instructions 17.0%
+ ~Mathlib.LinearAlgebra.Charpoly.Basic instructions -5.8%
- ~Mathlib.LinearAlgebra.Dimension instructions 8.4%
+ ~Mathlib.LinearAlgebra.DirectSum.Finsupp instructions -13.9%
- ~Mathlib.LinearAlgebra.DirectSum.TensorProduct instructions 11.5%
- ~Mathlib.LinearAlgebra.Eigenspace.Basic instructions 20.2%
- ~Mathlib.LinearAlgebra.FiniteDimensional instructions 7.4%
- ~Mathlib.LinearAlgebra.Finrank instructions 17.7%
+ ~Mathlib.LinearAlgebra.FreeAlgebra instructions -6.9%
- ~Mathlib.LinearAlgebra.FreeModule.Finite.Rank instructions 33.5%
- ~Mathlib.LinearAlgebra.Isomorphisms instructions 37.2%
- ~Mathlib.LinearAlgebra.Matrix.Charpoly.Basic instructions 5.5%
+ ~Mathlib.LinearAlgebra.Matrix.Charpoly.Coeff instructions -6.3%
- ~Mathlib.LinearAlgebra.Matrix.Diagonal instructions 8.5%
- ~Mathlib.LinearAlgebra.Projection instructions 6.2%
- ~Mathlib.LinearAlgebra.ProjectiveSpace.Basic instructions 8.5%
- ~Mathlib.LinearAlgebra.TensorAlgebra.Grading instructions 12.4%
- ~Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 instructions 5.4%
+ ~Mathlib.NumberTheory.LegendreSymbol.GaussSum instructions -7.9%
+ ~Mathlib.NumberTheory.NumberField.Norm instructions -6.0%
- ~Mathlib.Probability.ConditionalExpectation instructions 66.0%
- ~Mathlib.RingTheory.Artinian instructions 7.2%
+ ~Mathlib.RingTheory.FinitePresentation instructions -24.3%
+ ~Mathlib.RingTheory.FreeCommRing instructions -10.0%
- ~Mathlib.RingTheory.Ideal.Cotangent instructions 17.7%
- ~Mathlib.RingTheory.MatrixAlgebra instructions 12.6%
+ ~Mathlib.RingTheory.MvPolynomial.Homogeneous instructions -5.3%
+ ~Mathlib.RingTheory.MvPolynomial.Ideal instructions -6.8%
+ ~Mathlib.RingTheory.Nullstellensatz instructions -22.3%
+ ~Mathlib.RingTheory.Polynomial.Basic instructions -5.8%
+ ~Mathlib.RingTheory.Polynomial.GaussLemma instructions -6.1%
+ ~Mathlib.RingTheory.Polynomial.Quotient instructions -5.3%
- ~Mathlib.RingTheory.Polynomial.Vieta instructions 6.2%
+ ~Mathlib.RingTheory.RootsOfUnity.Minpoly instructions -35.2%
- ~Mathlib.RingTheory.SimpleModule instructions 31.1%
+ ~Mathlib.RingTheory.WittVector.Basic instructions -7.5%
+ ~Mathlib.RingTheory.WittVector.Defs instructions -9.4%
+ ~Mathlib.RingTheory.WittVector.Teichmuller instructions -15.9%
+ ~Mathlib.RingTheory.WittVector.WittPolynomial instructions -7.2%
- ~Mathlib.Topology.Algebra.UniformConvergence instructions 12.0% |
|
!bench |
|
Here are the benchmark results for commit 77b1bfa. Benchmark Metric Change
============================================================================
+ lint wall-clock -9.0%
- ~Mathlib.Algebra.Category.ModuleCat.EpiMono instructions 8.7%
- ~Mathlib.Algebra.Category.ModuleCat.Subobject instructions 5.6%
+ ~Mathlib.Algebra.Category.Ring.Adjunctions instructions -7.6%
+ ~Mathlib.Algebra.DirectSum.Ring instructions -24.2%
+ ~Mathlib.Algebra.EuclideanDomain.Instances instructions -17.8%
+ ~Mathlib.Algebra.FreeNonUnitalNonAssocAlgebra instructions -10.9%
+ ~Mathlib.Algebra.Group.TypeTags instructions -6.9%
+ ~Mathlib.Algebra.GroupRingAction.Subobjects instructions -6.2%
+ ~Mathlib.Algebra.Lie.Engel instructions -5.5%
+ ~Mathlib.Algebra.Lie.Matrix instructions -6.6%
+ ~Mathlib.Algebra.Lie.OfAssociative instructions -11.2%
+ ~Mathlib.Algebra.MonoidAlgebra.Basic instructions -9.3%
+ ~Mathlib.Algebra.MonoidAlgebra.Grading instructions -18.8%
+ ~Mathlib.Algebra.Order.Pi instructions -14.7%
+ ~Mathlib.Algebra.Order.Ring.WithTop instructions -19.6%
+ ~Mathlib.Algebra.Ring.Defs instructions -6.7%
+ ~Mathlib.Algebra.Star.Module instructions -11.4%
+ ~Mathlib.Algebra.Symmetrized instructions -5.5%
+ ~Mathlib.AlgebraicGeometry.EllipticCurve.Point instructions -9.1%
+ ~Mathlib.Analysis.Calculus.IteratedDeriv instructions -5.0%
+ ~Mathlib.Analysis.NormedSpace.Completion instructions -6.6%
+ ~Mathlib.Analysis.NormedSpace.Dual instructions -33.8%
+ ~Mathlib.Data.MvPolynomial.Funext instructions -6.3%
+ ~Mathlib.Data.Polynomial.Laurent instructions -5.0%
+ ~Mathlib.Data.Polynomial.Monomial instructions -9.6%
+ ~Mathlib.FieldTheory.Cardinality instructions -54.6%
+ ~Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure instructions -16.6%
+ ~Mathlib.FieldTheory.MvPolynomial instructions -14.8%
+ ~Mathlib.FieldTheory.PolynomialGaloisGroup instructions -8.3%
+ ~Mathlib.FieldTheory.SplittingField.Construction instructions -19.5%
- ~Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional instructions 5.6%
- ~Mathlib.LinearAlgebra.AffineSpace.Restrict instructions 7.3%
+ ~Mathlib.LinearAlgebra.Charpoly.Basic instructions -5.8%
+ ~Mathlib.LinearAlgebra.DirectSum.Finsupp instructions -13.9%
- ~Mathlib.LinearAlgebra.DirectSum.TensorProduct instructions 11.5%
+ ~Mathlib.LinearAlgebra.FiniteDimensional instructions -10.3%
+ ~Mathlib.LinearAlgebra.FreeAlgebra instructions -6.9%
- ~Mathlib.LinearAlgebra.FreeModule.Finite.Rank instructions 6.5%
- ~Mathlib.LinearAlgebra.Isomorphisms instructions 40.7%
- ~Mathlib.LinearAlgebra.Matrix.Charpoly.Basic instructions 5.7%
+ ~Mathlib.LinearAlgebra.Matrix.Charpoly.Coeff instructions -6.4%
+ ~Mathlib.NumberTheory.LegendreSymbol.GaussSum instructions -7.9%
+ ~Mathlib.NumberTheory.NumberField.Norm instructions -5.7%
+ ~Mathlib.RepresentationTheory.Maschke instructions -6.2%
+ ~Mathlib.RingTheory.FinitePresentation instructions -24.2%
+ ~Mathlib.RingTheory.FreeCommRing instructions -9.9%
- ~Mathlib.RingTheory.MatrixAlgebra instructions 12.7%
+ ~Mathlib.RingTheory.MvPolynomial.Homogeneous instructions -6.0%
+ ~Mathlib.RingTheory.MvPolynomial.Ideal instructions -6.8%
+ ~Mathlib.RingTheory.Nullstellensatz instructions -22.5%
+ ~Mathlib.RingTheory.Polynomial.Basic instructions -5.9%
+ ~Mathlib.RingTheory.Polynomial.GaussLemma instructions -6.1%
+ ~Mathlib.RingTheory.Polynomial.Quotient instructions -5.2%
- ~Mathlib.RingTheory.Polynomial.Vieta instructions 6.3%
+ ~Mathlib.RingTheory.RootsOfUnity.Minpoly instructions -35.1%
- ~Mathlib.RingTheory.SimpleModule instructions 24.2%
+ ~Mathlib.RingTheory.WittVector.Basic instructions -7.6%
+ ~Mathlib.RingTheory.WittVector.Defs instructions -9.4%
+ ~Mathlib.RingTheory.WittVector.Teichmuller instructions -16.0%
+ ~Mathlib.RingTheory.WittVector.WittPolynomial instructions -7.1% |
|
✌️ mattrobball can now approve this pull request. To approve and merge a pull request, simply reply with |
|
bors merge |
This removes redundant field values of the form `add := add` for smaller terms and less unfolding during unification.
A list of all files containing a structure instance of the form `{ a1, ... with x1 := val, ... }` where some `xi` is a field of some `aj` was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.
Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg `add := add` and not `toFun` (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.
It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.
|
Build failed (retrying...): |
This removes redundant field values of the form `add := add` for smaller terms and less unfolding during unification.
A list of all files containing a structure instance of the form `{ a1, ... with x1 := val, ... }` where some `xi` is a field of some `aj` was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.
Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg `add := add` and not `toFun` (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.
It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.
|
Build failed (retrying...): |
This removes redundant field values of the form `add := add` for smaller terms and less unfolding during unification.
A list of all files containing a structure instance of the form `{ a1, ... with x1 := val, ... }` where some `xi` is a field of some `aj` was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.
Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg `add := add` and not `toFun` (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.
It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.
|
Build failed (retrying...): |
|
bors merge |
This removes redundant field values of the form `add := add` for smaller terms and less unfolding during unification.
A list of all files containing a structure instance of the form `{ a1, ... with x1 := val, ... }` where some `xi` is a field of some `aj` was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.
Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg `add := add` and not `toFun` (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.
It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.
|
This PR was included in a batch that was canceled, it will be automatically retried |
This removes redundant field values of the form `add := add` for smaller terms and less unfolding during unification.
A list of all files containing a structure instance of the form `{ a1, ... with x1 := val, ... }` where some `xi` is a field of some `aj` was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.
Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg `add := add` and not `toFun` (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.
It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.
|
Pull request successfully merged into master. Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
This removes redundant field values of the form `add := add` for smaller terms and less unfolding during unification.
A list of all files containing a structure instance of the form `{ a1, ... with x1 := val, ... }` where some `xi` is a field of some `aj` was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.
Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg `add := add` and not `toFun` (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.
It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.
This removes redundant field values of the form
add := addfor smaller terms and less unfolding during unification.A list of all files containing a structure instance of the form
{ a1, ... with x1 := val, ... }where somexiis a field of someajwas generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg
add := addand nottoFun(though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.