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

feat: optimize LWG and NWG #2512

Merged
merged 31 commits into from
Aug 2, 2024
Merged

feat: optimize LWG and NWG #2512

merged 31 commits into from
Aug 2, 2024

Conversation

0xVolosnikov
Copy link
Contributor

@0xVolosnikov 0xVolosnikov commented Jul 26, 2024

What ❔

Separating recursive circuits from the AggregationWrapper struct allows them to be used separately and significantly reduces data duplication in the storage.

Processing L/N circuits in parallel speeds up processing, also providing an adjustable limits on peak memory.

@0xVolosnikov
Copy link
Contributor Author

@EmilLuta
Copy link
Contributor

So, I looked at both this fella' and harness#168. Maybe I'm tired, but my understanding is that the logic stays the same. What is different is that instead of saving next_aggregations twice (as a triplet), we'll save a tuple of 2 (next_aggregation) and then a separated entry (recursive_circuits).

So the gain here is us reducing storage costs and memory load (by a factor of 2). LMK if I misunderstood the PR. Otherwise, LGTM.

Copy link
Contributor

@EmilLuta EmilLuta left a comment

Choose a reason for hiding this comment

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

We don't want to merge the PR as is, let's deal with TODOs and make sure we publish the crates as intended.

@0xVolosnikov
Copy link
Contributor Author

0xVolosnikov commented Jul 29, 2024

The most important thing here is the fact that recursive_circuits are taken out of AggregationWrapper struct. So we will not save them twice for no reason.

Regarding the memory load: it is reduced by more than 2 times, rather by factor of 3-5, since serializing and sending the structure has an additional overhead, proportional to the size of the structure.

@0xVolosnikov 0xVolosnikov marked this pull request as draft July 30, 2024 08:17
@0xVolosnikov 0xVolosnikov marked this pull request as ready for review August 2, 2024 09:08
Cargo.lock Outdated Show resolved Hide resolved
@0xVolosnikov 0xVolosnikov added this pull request to the merge queue Aug 2, 2024
Merged via the queue into main with commit 0d00650 Aug 2, 2024
53 checks passed
@0xVolosnikov 0xVolosnikov deleted the vv-optimize-lwg-nwg branch August 2, 2024 11:59
github-merge-queue bot pushed a commit that referenced this pull request Aug 2, 2024
🤖 I have created a release *beep* *boop*
---


##
[16.2.0](prover-v16.1.0...prover-v16.2.0)
(2024-08-02)


### Features

* **configs:** Do not panic if config is only partially filled
([#2545](#2545))
([db13fe3](db13fe3))
* Introduce more tracing instrumentation
([#2523](#2523))
([79d407a](79d407a))
* New prover documentation
([#2466](#2466))
([1b61d07](1b61d07))
* optimize LWG and NWG
([#2512](#2512))
([0d00650](0d00650))
* Poll the main node for the next batch to sign (BFT-496)
([#2544](#2544))
([22cf820](22cf820))
* Remove CI and docker images for CPU prover & compressor
([#2540](#2540))
([0dda805](0dda805))
* Remove unused VKs, add docs for BWG
([#2468](#2468))
([2fa6bf0](2fa6bf0))
* Support sending logs via OTLP
([#2556](#2556))
([1d206c0](1d206c0))
* Update to consensus 0.1.0-rc.4 (BFT-486)
([#2475](#2475))
([ff6b10c](ff6b10c))
* **vlog:** New vlog interface + opentelemtry improvements
([#2472](#2472))
([c0815cd](c0815cd))
* **witness_vector_generator:** Make it possible to run multiple wvg
instances in one binary
([#2493](#2493))
([572ad40](572ad40))
* **zk_toolbox:** use configs from the main repo
([#2470](#2470))
([4222d13](4222d13))


### Bug Fixes

* **prover:** Parallelize circuit metadata uploading for BWG
([#2520](#2520))
([f49720f](f49720f))
* **prover:** Reduce database connection overhead for BWG
([#2543](#2543))
([c2439e9](c2439e9))
* **witness_generator:** Only spawn 1 prometheus exporter per witness
generator
([#2492](#2492))
([b9cb222](b9cb222))


### Reverts

* "feat: Poll the main node for the next batch to sign (BFT-496)"
([#2574](#2574))
([72d3be8](72d3be8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Danil <deniallugo@gmail.com>
@@ -26,12 +26,20 @@ pub struct FriWitnessGeneratorConfig {

pub prometheus_listener_port: Option<u16>,

/// This value corresponds to the maximum number of circuits kept in memory at any given time for a BWG.
/// This value corresponds to the maximum number of circuits kept in memory at any given time for a BWG/LWG/NWG.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why we decided to have a single value for all components. They're somewhat different on usage. I don't think we should change this until the first need, but I can see this popping up soon.

Copy link
Member

Choose a reason for hiding this comment

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

We can override the value per-component, so it should be fine.

Copy link
Contributor

@EmilLuta EmilLuta left a comment

Choose a reason for hiding this comment

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

LGTM.

ZkSyncRecursiveLayerCircuit,
)>,
);
pub struct AggregationWrapper(pub Vec<(u64, RecursionQueueSimulator<GoldilocksField>)>);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Would be nice to turn those into some DTO structs.

github-merge-queue bot pushed a commit that referenced this pull request Aug 7, 2024
🤖 I have created a release *beep* *boop*
---


##
[24.15.0](core-v24.14.0...core-v24.15.0)
(2024-08-07)


### Features

* optimize LWG and NWG
([#2512](#2512))
([0d00650](0d00650))
* Poll the main node API for attestation status - relaxed (BFT-496)
([#2583](#2583))
([b45aa91](b45aa91))
* **zk_toolbox:** allow to run `zk_inception chain create`
non-interactively
([#2579](#2579))
([555fcf7](555fcf7))


### Bug Fixes

* **core:** Handle GCS Response retriable errors
([#2588](#2588))
([4b74092](4b74092))
* **node:** respect namespaces configuration
([#2578](#2578))
([e2d9060](e2d9060))
* **vm-runner:** Fix data race in storage loader
([1810b78](1810b78))


### Reverts

* "feat: Poll the main node for the next batch to sign (BFT-496)"
([#2574](#2574))
([72d3be8](72d3be8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: zksync-era-bot <zksync-era-bot@users.noreply.github.com>
Co-authored-by: Roman Brodetski <rb@matterlabs.dev>
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.

3 participants