This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joonazan
force-pushed
the
jms-fix-memory-use
branch
4 times, most recently
from
January 12, 2024 08:59
9b2bcc9
to
997463c
Compare
joonazan
force-pushed
the
jms-fix-memory-use
branch
3 times, most recently
from
January 24, 2024 18:02
a8a88e9
to
70351ec
Compare
The destination of replace isn't used later, so setting it to an empty Vec does nothing.
Still needs further cleanup. This version doesn't reduce memory use much, the focus here is on changing the API. I had to hardcode GoldilocksField instead of parameterizing everything by field. The trait bounds required were ridiculous and caused 30 min long typechecking.
I had assumed that InstanceWitness -> circuit type is a proper function. It is not.
joonazan
force-pushed
the
jms-fix-memory-use
branch
from
January 25, 2024 10:24
70351ec
to
a8e3b26
Compare
I get the same failures and timeouts when running the tests before and after this PR, so I guess it passes... |
We should rollout it on staging, generate witness for the full block, and basically compare them (those are serializable structures, so just compare bytes) |
@shamatar A note about comparing witnesses: simple diffing will indicate they have changed because the circuits are in a valid but different order. I used the following script to diff circuits. import os, os.path, filecmp
def sorted_files(dir):
return map(lambda x: os.path.join(dir, x), sorted(os.listdir(dir), key=file_order))
def file_order(filename):
[a, b, c, *r] = os.path.basename(filename).split("_")
return (int(a), int(c), int(b))
for a, b in zip(sorted_files("reference_artifacts/prover_jobs_fri"), sorted_files("artifacts/prover_jobs_fri")):
if not filecmp.cmp(a, b):
print("mismatch", a, b) We'll do comprehensive testing next week. I'm unavailable tomorrow. I am very confident that the output of this version is identical to 1.4.1 in all other respects. |
joonazan
force-pushed
the
jms-fix-memory-use
branch
from
January 25, 2024 17:24
fc3e302
to
1050071
Compare
joonazan
force-pushed
the
jms-fix-memory-use
branch
from
January 25, 2024 17:56
1713a78
to
cd639c4
Compare
github-merge-queue bot
pushed a commit
to matter-labs/zksync-era
that referenced
this pull request
Jan 31, 2024
## What ❔ Uses an [updated zkevm_test_harness](matter-labs/era-zkevm_test_harness#57) that uses less memory. The updated crate takes callback functions instead of returning a vector of all results. We may have to think about how to not keep the database open the whole time the callbacks are coming in. ## Why ❔ Proving batches currently uses memory proportional to the batch size, which is not ok for large batches. --------- Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com> Co-authored-by: AntonD3 <74021421+AntonD3@users.noreply.github.com> Co-authored-by: Stanislav Breadless <stanislavbezkor@gmail.com> Co-authored-by: perekopskiy <53865202+perekopskiy@users.noreply.github.com> Co-authored-by: pompon0 <pompon.pompon@gmail.com> Co-authored-by: Dustin Brickwood <dustinbrickwood204@gmail.com> Co-authored-by: Igor Borodin <hatemosphere@protonmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What ❔
Enables improving peak memory use by computing circuits incrementally.
The API between this crate and the witness generator changes significantly. Instead of returning circuits, this crate now takes callbacks which it calls whenever a new circuit is ready. It could directly take a channel instead but I feel that is maybe not generic enough.
This PR incrementalizes just one type of circuit to make sure that it is possible.
Also removes unnecessary datastructures, clones etc. which improves memory use as well.
Why ❔
We have to improve memory use to be able to process larger batches on reasonable computers.
The new API allows emitting circuits as soon as possible instead of keeping around circuit inputs till the end and then building all of them. I measured that the vast majority of memory goes into storing the inputs of RAM circuits and MainVM circuits. Fixing those could solve all our memory trouble.
Even with every circuit type incrementalized, an array of all ClosedFormInputCompactFormWitnesses is collected. I don't know how hard it is to get rid of that or if it is big enough to be problematic.