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

Fix mockprover memory #85

Merged
merged 4 commits into from
Mar 14, 2024
Merged

Fix mockprover memory #85

merged 4 commits into from
Mar 14, 2024

Conversation

DreamWuGit
Copy link
Member

@DreamWuGit DreamWuGit commented Mar 13, 2024

issue #86
in MockProver fork method, there are some fields' clone operation happens in following code snippets.
among them self.cs.clone() and self.instance.clone() increase about 90M memory costs each time.
in very complex test tool tests(like create2_recursive_xxx) , there are > 4000 regions being generated and result in more than 4000 times clone operations. this increase the peak memory remarkably. for normal test, there are only about 100 sub regions used, so no much memory going up.

sub_cs.push(Self {
                k: self.k,
                n: self.n,
                cs: self.cs.clone(),
                regions: vec![],
                current_region: None,
                fixed_vec: self.fixed_vec.clone(),
                fixed,
                advice_vec: self.advice_vec.clone(),
                advice,
                advice_prev: self.advice_prev.clone(),
                instance: self.instance.clone(),
                selectors_vec: self.selectors_vec.clone(),
                selectors,
                challenges: self.challenges.clone(),
                permutation: None,
                rw_rows: sub_range.clone(),
                usable_rows: self.usable_rows.clone(),
                current_phase: self.current_phase,
            });
        }

fix solution:
change both self.cs and self.instance to Arc type, after testing against latest zkevm develop branch(disabled batch_inv feature) peak memory size down to less than 100G while old test run take >300 G

[2024-03-13T02:16:08Z DEBUG halo2_proofs::dev] memory usage of mockprover fork_4107 ends vm_size 81 GB : vm_rss: 68GB

Copy link

@lispc lispc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seesm good.

@DreamWuGit DreamWuGit marked this pull request as ready for review March 13, 2024 07:17
@Velaciela
Copy link

double checked by using real trace and halo2-gpu, peak mem < 120GB after this PR

@kunxian-xia kunxian-xia merged commit c90df71 into v1.1 Mar 14, 2024
13 of 15 checks passed
@kunxian-xia kunxian-xia deleted the fix_mockprover_memory branch March 14, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants