onurinanc / noir-bn254

BN254 Pairing Implementation in Noir
MIT License
20 stars 0 forks source link

OOM while trying to compile on Noir versions past 0.9.0 #3

Open wwared opened 11 months ago

wwared commented 11 months ago

I've been trying to compile this codebase with newer versions of Noir, mainly trying with 0.11.1-aztec.0 (to try and deploy a contract using it in the sandbox) and 0.14.1, and I'm running into an out-of-memory issue, and just giving it more memory does not seem to be enough for it to compile.

Trying to narrow things down, it looks like one of the main culprits is Fp12 exponentiation, since I observe the OOM in tests test_fp12_final_exp and test_final_exponentiation, and not just when compiling the pairing function. I've commented out chunks of the final_exponentiate code to try and identify which specific calls make the compiler use so much memory, and landed in the Fp12::exponentiation function, which in my tests makes noir use over 900GiB of RAM during compilation before eventually running into a stack overflow if you give it enough RAM/swap space to keep running without OOMing.

I've also quickly tried other noir versions, and it seems like any version beyond 0.9.0 has issues compiling this code, so I'm guessing it's probably related to the SSA backend that was refactored and replaced in 0.10.0? I'm not sure if the code in this repo is just naturally leading to a large circuit that can't be compiled with the refactored codebase, or if there is something in how the code is written/organized that is making Fp12::exponentiation trigger some bug in the compiler.

Have you made any attempts at compiling with newer versions of Noir, or do you have any insight on the root cause of this memory regression?

Thanks!