This note shows a pseudocode of create_proof
of halo2_proofs
and counts the memory usage for each moment.
From the computation, currently peak memory usage could be found at step 9:
Here is a script to reproduce the actual peak memory usage https://gist.github.com/han0110/676ba81904a5e99d5ff7d8961cebaed5.
instance_lagranges
alreadyperm_grand_product_extended_lagranges
also on the fly so it doesn't overlap with lookup's auxiliary extended lagrangesWith these, the peak memory usage reduces to:
In fact:
So we can compute quotient chunk by chunk without needing extended lagrange of other monomials in memory all at once, so degree won't have affect on peak memory usage anymore.
But with a performance drawback, is the need to compute d - 1
extra times of coset(monomial, omega_nd_to_i)
, which seems fine because it's not that expensive.
With this, the peak memory usage reduces to:
To reduce even more, we can also discard the extended lagranges in proving key, and just compute them on the fly.
So the peak memory usage is roughly estimated to 2x sum of all polynomials size.