-
Couldn't load subscription status.
- Fork 487
perf: Improve GKR memory usage #1608
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves memory usage in GKR implementation by introducing a memory pool for field elements to reduce heap allocations. The optimization achieves significant memory reduction: from 20292 MB to 4403 MB (4.6x improvement) on benchmarks.
Key changes include:
- Implementation of a synchronous memory pool system in
gateAPIto reuse field element allocations - Replacement of global API instances with local instances across all curve implementations
- Simplification of test benchmarks by removing complex file caching logic
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| std/hash/mimc/gkr-mimc/gkr-mimc_test.go | Renamed circuit types and simplified benchmark by removing file caching |
| std/permutation/gkr-mimc/gkr-mimc_test.go | Renamed circuit types for consistency |
| internal/gkr/*/gkr.go | Added memory pool to gateAPI with element allocation/deallocation methods |
| internal/gkr/*/gate_testing.go | Updated to use local gateAPI instances |
| internal/gkr/*/solver_hints.go | Added local gateAPI instances with proper cleanup |
| internal/generator/backend/template/gkr/*.tmpl | Updated templates to generate optimized code |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Closed in favor of #1616 |
This PR introduces a simple memory pool to massively reduce the number of heap allocations of single field elements introduced by the new GKR API.
On the benchmark
std/hash/mimc/gkr-mimc/BenchmarkMerkleTreeand a similar one for thegkr-mimccurrently on the Linea monorepo, with an hpc6a.48xlarge instance, we get:This PR: 3937 MB
feat/gkr/hashes: 20292 MB (5.15x improvement)linea-monorepo@main: 7229 MB (1.83x improvement)