[Merged by Bors] - chore(RingTheory/AdicCompletion): manual instances#14534
[Merged by Bors] - chore(RingTheory/AdicCompletion): manual instances#14534
Conversation
PR summary 7330fdbaf7Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
!bench |
|
Here are the benchmark results for commit db687bf. Benchmark Metric Change
========================================================================
- ~Mathlib.RingTheory.AdicCompletion.Algebra instructions 15.4%
- ~Mathlib.RingTheory.AdicCompletion.Basic instructions 29.5%
+ ~Mathlib.RingTheory.AdicCompletion.Functoriality instructions -61.6% |
|
!bench |
|
Here are the benchmark results for commit ddef0a4. Benchmark Metric Change
==================================================================
- ~Mathlib.RingTheory.AdicCompletion.Algebra instructions 15.4%
- ~Mathlib.RingTheory.AdicCompletion.Basic instructions 29.5% |
This reverts commit ddef0a4.
| instance : One (AdicCompletion I R) where | ||
| one := ⟨1, by simp⟩ | ||
|
|
||
| instance : CommRing (AdicCompletion I R) where |
There was a problem hiding this comment.
Function.Injective.commRing might help
There was a problem hiding this comment.
I changed it, not entirely sure its better now though.
There was a problem hiding this comment.
I did another benchmark comparing the version with Function.Injective.commRing and the manual one: http://speed.lean-fro.org/mathlib4/compare/04e26275-26be-4d08-8dd1-ffeb4e23bd0e/to/e7b27246-a3e6-496a-b552-ff4b45c7236e?hash2=55cf90705c3509ab5da127b7ecd4db0e147af667
It seems the manual one is significantly faster, so I suggest we leave it at this.
|
!bench |
|
Here are the benchmark results for commit 20fe104. Benchmark Metric Change
========================================================================
- ~Mathlib.RingTheory.AdicCompletion.Algebra instructions 28.6%
- ~Mathlib.RingTheory.AdicCompletion.Basic instructions 47.8%
+ ~Mathlib.RingTheory.AdicCompletion.Functoriality instructions -60.3% |
|
!bench |
|
Here are the benchmark results for commit 6b20ecb. Benchmark Metric Change
========================================================================
- ~Mathlib.RingTheory.AdicCompletion.Algebra instructions 27.9%
- ~Mathlib.RingTheory.AdicCompletion.Basic instructions 34.4%
+ ~Mathlib.RingTheory.AdicCompletion.Functoriality instructions -61.7% |
|
!bench |
| unseal smul' in | ||
| unseal mul in | ||
| /-- A priori `AdicCompletion I R` has two `AdicCompletion I R`-module instances. | ||
| Both agree definitionally. -/ | ||
| example : module I = @Algebra.toModule (AdicCompletion I R) |
There was a problem hiding this comment.
I think the two unseals here are a problem: In the other PR in the AsTensorProduct file, I had to add the same unseals because Lean can no longer identify these two instances as equal:
mathlib4/Mathlib/RingTheory/AdicCompletion/AsTensorProduct.lean
Lines 133 to 138 in abf5c56
mul and smul' irreducible?
|
Here are the benchmark results for commit 571a2f2. Benchmark Metric Change
========================================================================
- ~Mathlib.RingTheory.AdicCompletion.Algebra instructions 30.9%
- ~Mathlib.RingTheory.AdicCompletion.Basic instructions 36.4%
+ ~Mathlib.RingTheory.AdicCompletion.Functoriality instructions -61.7% |
|
It is out-dated but |
Ah yes, no it did not change its name, but then adding the |
|
Oh well, it was minor I think anyway |
|
So should I go for a final benchmark? |
|
There is a good chance it won't make it in without using the |
|
I had tried out the version with The first run is with |
|
Anything else I should test? |
|
!bench |
|
Here are the benchmark results for commit 400c96f. Benchmark Metric Change
========================================================================
+ ~Mathlib.RingTheory.AdicCompletion.Algebra instructions -15.3%
+ ~Mathlib.RingTheory.AdicCompletion.Functoriality instructions -64.1% |
|
What's the effect on |
|
Benchmark is upcoming. My local one looks very good, i.e. comparable to the performance with explicit instances. |
|
Benchmark is there. This is the comparsion: First commit: manual instances I think this looks promising, so I'll revert the commits adding the |
|
Also please make a separate dependent PR with the |
Since #11521 currently has merge conflicts, what should I do to create the dependent PR? Maybe from #11521 the actual |
|
I forgot it wasn't just the single file. I'll split it later today. |
|
Anything else I should do for this PR to be merged? |
|
I don't think so. Thanks for your patience. bors merge |
Instead of inferring `AddCommGroup`, `Module`, etc. instances for `AdicCompletion I M` from being a submodule, we explicitly spell out the definitions to improve performance. Also marks some definitions as `noncomputable` to save time spent on compilation. See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Adic.20completion.20is.20slow.
|
Pull request successfully merged into master. Build succeeded: |
|
Thanks a lot for the guidance and for helping analyzing this! |
Instead of inferring
AddCommGroup,Module, etc. instances forAdicCompletion I Mfrom being a submodule, we explicitly spell out the definitions to improve performance.Also marks some definitions as
noncomputableto save time spent on compilation.See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Adic.20completion.20is.20slow.