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

Thousands of hard-coded constants slows down execution time by 7x. #6457

Closed
iAmMichaelConnor opened this issue Nov 5, 2024 · 2 comments · Fixed by #6558
Closed

Thousands of hard-coded constants slows down execution time by 7x. #6457

iAmMichaelConnor opened this issue Nov 5, 2024 · 2 comments · Fixed by #6558
Assignees

Comments

@iAmMichaelConnor
Copy link
Collaborator

2 potential bugs here.

Checkout this branch: iAmMichaelConnor/blob-lib#5

Update the Nargo.toml to point to v0.4.0 (or later... I was testing it against main, locally).

Turn your attention to the config.nr and negative_roots.nr files. You'll see thousands of hard-coded constants.

Now observe:

Run nargo execute on main.nr. This took 28 minutes on my old 2019 MacBook Pro i9.

Now comment-out all those constants and uncomment the "array of zeros" version. Do it in both config.nr and negative_roots.nr.

E.g. see this pic for what to uncomment:

Image

Again, run nargo execute on main.nr. It'll break with some kind of "stack too deep" error. Very strange.

Now delete those thousands of lines of commented-out hard-coded constants.

Again, run nargo execute on main.nr. The "stack too deep" error will disappear. This took 3 mins 50 seconds.

Observations:

  • Those thousands of hard-coded constants slow-down execution by 7x.
  • Huge comments break Noir.

Thanks to @MirandaWood for first spotting this!

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Nov 5, 2024
@TomAFrench
Copy link
Member

I'm guessing this is due to having many copies of ROOTS being inlined across the codebase which tanks compilation speed due to the amounts of memory necessary. I'd expect that #6071 would help with this.

@sirasistant
Copy link
Contributor

While makearray could help since it'd deduplicate constants per function, I think what would be the most effective solution to this is introducing globals in SSA, so this constant would appear exactly once in the program

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
4 participants