leo icon indicating copy to clipboard operation
leo copied to clipboard

[Bug] compiling 18 `i32` exponent operations produces 30gb project folder

Open 0rphon opened this issue 2 years ago • 4 comments

🐛 Bug Report

this seems to have basically the same cause as the OOM errors.

every time you do an i32 ** i32 operation with input it adds about 1gb to the proving key size. the following code leads to a proving key that's over 16gb and a json that's over 13gb. i could have done more iterations, but this program took 50gb of ram and anything more than that just OOM's me.

Code snippet to reproduce

function main(x: i32) {
    for i in 0..18 {
        let y = x ** 2;
    }
}

Your Environment

  • leo commit 7e24b38620f30dda816b1a76ae4e6486b8a838e0
  • rustc version 1.55.0-nightly
  • Windows 10.0.19043 (Windows 10 Pro) [64-bit]

0rphon avatar Jun 17 '21 01:06 0rphon

Might be fixed by #933.

gluax avatar Jun 17 '21 17:06 gluax

Replacing exponentiation with multiplication like this:

function main(x: i32) {
    for i in 0..18 {
        let y = x * x;
    }
}

Reduces size of outputs folder to ~200MB.

damirka avatar Jun 17 '21 17:06 damirka

In the meantime, we should put in the leo documentation to be careful with exponentiation.

gluax avatar Jun 17 '21 17:06 gluax

On a related note, it's probably not a cool idea to have square be some of the first code people see in the docs. It gives the unreasonable impression that leo is slow. This one already uses multiplication, but it still exhibits a slowdown.

nhynes avatar Jul 26 '22 09:07 nhynes

My project folder after compiling the above snippet is ~200mb. Also the square example in the flying tour has been removed.

collinc97 avatar Jan 05 '23 03:01 collinc97