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

Benchmarking each step of the compilation process #4658

Closed
vezenovm opened this issue Mar 27, 2024 · 4 comments · Fixed by #4659
Closed

Benchmarking each step of the compilation process #4658

vezenovm opened this issue Mar 27, 2024 · 4 comments · Fixed by #4659
Labels
compiler enhancement New feature or request

Comments

@vezenovm
Copy link
Contributor

Problem

Every so often we have bugs that arise such as #4395 where users cannot compile certain valid code due to compile time blowup.

It would be easier to nail down and debug these programs if we had an option to similar to --show-ssa that displayed how much time we are spending on each compilation pass.

Happy Case

We should be able to discern how much time is spent per compilation step.

Ideally after this is done, we could have a similar tool to the gate checks count that displays how compilation times increase/decrease on certain tests due to PRs.

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

@vezenovm vezenovm added enhancement New feature or request compiler labels Mar 27, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Mar 27, 2024
@TomAFrench
Copy link
Member

NOIR_LOG=trace nargo compile will currently display timings for all of the different SSA passes btw.

@vezenovm
Copy link
Contributor Author

@TomAFrench Thank you good to know I forgot about that. I will change this issue to make a tool similar to gate counts check then.

@vezenovm
Copy link
Contributor Author

I just ran that and it is slightly hard to discern exactly the timings as everything is just timestamped. Perhaps it would be worth to still have a command that pretty prints some benchmarking info.

@vezenovm
Copy link
Contributor Author

vezenovm commented Mar 27, 2024

Can we have the trace output the difference between enter and exit?:

2024-03-27T16:33:32.975201Z TRACE compile_no_check{function_name="main"}:create_circuit:ssa_generation:fold_constants: noirc_evaluator::ssa::opt::constant_folding: enter
2024-03-27T16:33:34.866814Z TRACE compile_no_check{function_name="main"}:create_circuit:ssa_generation:fold_constants: noirc_evaluator::ssa::opt::constant_folding: exit
After Constant Folding:: 1891

github-merge-queue bot pushed a commit that referenced this issue Mar 28, 2024
# Description

## Problem\*

Resolves #4658

## Summary\*

I was already timing things for a separate issue so I decided to push
this PR. I felt this provided a nice temporary solution. If we deem that
the `tracing` crate can still be used for pretty printing the timings of
each codegen pass we can switch to that in a follow-up, and for now this
provides an easy way to check the timings of each codegen pass.

Example output:
```
After Defunctionalization:: 0 ms
After Removing Paired rc_inc & rc_decs:: 0 ms
After Inlining:: 0 ms
After Mem2Reg:: 0 ms
After Assert Constant:: 0 ms
After Unrolling:: 13 ms
After Simplifying:: 0 ms
After Flattening:: 9 ms
After Removing Bit Shifts:: 0 ms
After Mem2Reg:: 19 ms
After Constant Folding:: 3 ms
After Constraint Folding:: 3 ms
After Dead Instruction Elimination:: 0 ms
SSA to Brillig: 0 ms
SSA to ACIR: 14 ms
``` 

## Additional Context



## Documentation\*

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

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: jfecher <[email protected]>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Mar 28, 2024
TomAFrench pushed a commit that referenced this issue Apr 3, 2024
# Description

## Problem\*

Resolves #4658

## Summary\*

I was already timing things for a separate issue so I decided to push
this PR. I felt this provided a nice temporary solution. If we deem that
the `tracing` crate can still be used for pretty printing the timings of
each codegen pass we can switch to that in a follow-up, and for now this
provides an easy way to check the timings of each codegen pass.

Example output:
```
After Defunctionalization:: 0 ms
After Removing Paired rc_inc & rc_decs:: 0 ms
After Inlining:: 0 ms
After Mem2Reg:: 0 ms
After Assert Constant:: 0 ms
After Unrolling:: 13 ms
After Simplifying:: 0 ms
After Flattening:: 9 ms
After Removing Bit Shifts:: 0 ms
After Mem2Reg:: 19 ms
After Constant Folding:: 3 ms
After Constraint Folding:: 3 ms
After Dead Instruction Elimination:: 0 ms
SSA to Brillig: 0 ms
SSA to ACIR: 14 ms
``` 

## Additional Context



## Documentation\*

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

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: jfecher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants