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

Optimize the elaborator #5194

Closed
Tracked by #4594
jfecher opened this issue Jun 6, 2024 · 0 comments · Fixed by #5230
Closed
Tracked by #4594

Optimize the elaborator #5194

jfecher opened this issue Jun 6, 2024 · 0 comments · Fixed by #5230
Labels
enhancement New feature or request

Comments

@jfecher
Copy link
Contributor

jfecher commented Jun 6, 2024

Problem

Initial tests against the aztec-packages repository suggest the elaborator is roughly 2-4x as slow as our current name resolution and type checking passes.

Happy Case

We should optimize the elaborator since it theoretically should be no slower than our existing solution.

We could look for cases in which large objects, e.g. FuncMetas are merged or profile with a flame graph.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher jfecher added the enhancement New feature or request label Jun 6, 2024
github-merge-queue bot pushed a commit that referenced this issue Jun 12, 2024
# Description

## Problem\*

Resolves #5194

## Summary\*

Fixes a performance issue where the elaborator was ~2x as slow running
`nargo t --use-elaborator` on aztec-nr versus the same tests without the
elaborator (4s versus 2s).

Found via flamegraph - `self.type_variables` wasn't cleared after each
function was elaborated. This Vec is meant to just store type variables
local to a function so that we can check if any need type hints after it
is done but since it wasn't cleared out, we'd be checking an
increasingly large Vec for each function.

## Additional Context

With this change the elaborator is slightly faster (but not noticeably)
than our current code. 1.9 versus 2.0s average across 10 runs for `nargo
t` (with lower std. deviation than our current code as well).

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant