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: memory fragmentation fixes to cut UltraHonk memory usage by 26% #11895

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lucasxia01
Copy link
Contributor

@lucasxia01 lucasxia01 commented Feb 10, 2025

prove_ultra_honk on the verify_honk_proof circuit goes from 3059.63MiB to 2251.31MiB, a decrease of 26%.

The fix hinges on a couple key issues: we want to deallocate large objects when we don't need them anymore and we need to be careful with our vector usage.

First, we should deallocate the builder after the prover is constructed and before we call construct_proof, and we should also deallocate the commitment_key during sumcheck since we do not need to commit to any polynomials during that phase.

Second, this deallocation of the commitment key does not actually help memory that much, in large part due to fragmentation. I discovered that our usage of the manifest, which uses vectors for each round data, caused tiny vectors to be littered across memory, often breaking up what otherwise would be a large contiguous block of memory.

With this in mind, we now only use the manifest when we build in debug mode and also if we specify that we want the manifest specifically, i.e. for the manifest tests.

@lucasxia01 lucasxia01 self-assigned this Feb 10, 2025
@lucasxia01 lucasxia01 changed the title fix: memory fragmentation fixes to cut UltraHonk memory usage by 33% #11816 fix: memory fragmentation fixes to cut UltraHonk memory usage by 26% #11816 Feb 10, 2025
@lucasxia01 lucasxia01 changed the title fix: memory fragmentation fixes to cut UltraHonk memory usage by 26% #11816 fix: memory fragmentation fixes to cut UltraHonk memory usage by 26% Feb 10, 2025
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.

1 participant