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

[Merged by Bors] - perf: improve to_additive performance #1060

Closed
wants to merge 18 commits into from

Conversation

fpvandoorn
Copy link
Member

@fpvandoorn fpvandoorn commented Dec 15, 2022

Using

def Ones : ℕ → Q(Nat)
| 0     => q(1)
| (n+1) => q($(Ones n) + $(Ones n))

The new to_additive takes 45ms on Ones 500 (higher gives stack overflows)
The old to_additive takes 13794ms on Ones 17 (exponential in the argument)
There is still one issue workaround by using transform in etaExpand.

  • Remove replaceRecM and replaceRecMeta that are exponentially slow
  • Remove replaceRecTraversal because its interface is less convenient than replaceRec

Apparently this now fails because of import Qq...

@semorrison
Copy link
Contributor

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Dec 16, 2022
@bors
Copy link

bors bot commented Dec 16, 2022

Canceled.

@semorrison
Copy link
Contributor

bors merge

@bors
Copy link

bors bot commented Dec 16, 2022

Canceled.

@semorrison
Copy link
Contributor

bors merge

bors bot pushed a commit that referenced this pull request Dec 16, 2022
Using
```
def Ones : ℕ → Q(Nat)
| 0     => q(1)
| (n+1) => q($(Ones n) + $(Ones n))
```
The new `to_additive` takes `45ms` on `Ones 500` (higher gives stack overflows)
The old `to_additive` takes `13794ms` on `Ones 17` (exponential in the argument)
There is still one issue workaround by using `transform` in `etaExpand`.

* Remove `replaceRecM` and `replaceRecMeta` that are exponentially slow
* Remove `replaceRecTraversal` because its interface is less convenient than `replaceRec`



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Dec 16, 2022

Build failed:

@semorrison
Copy link
Contributor

@siddhartha-gadgil's #1043 resulted in import loops here, which I'm resolving by splitting Mathlib.Init.Data.Nat.Basic.

@semorrison
Copy link
Contributor

bors merge

bors bot pushed a commit that referenced this pull request Dec 16, 2022
Using
```
def Ones : ℕ → Q(Nat)
| 0     => q(1)
| (n+1) => q($(Ones n) + $(Ones n))
```
The new `to_additive` takes `45ms` on `Ones 500` (higher gives stack overflows)
The old `to_additive` takes `13794ms` on `Ones 17` (exponential in the argument)
There is still one issue workaround by using `transform` in `etaExpand`.

* Remove `replaceRecM` and `replaceRecMeta` that are exponentially slow
* Remove `replaceRecTraversal` because its interface is less convenient than `replaceRec`



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Dec 16, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title perf: improve to_additive performance [Merged by Bors] - perf: improve to_additive performance Dec 16, 2022
@bors bors bot closed this Dec 16, 2022
@bors bors bot deleted the toAdditivePerformance branch December 16, 2022 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants