-
Notifications
You must be signed in to change notification settings - Fork 498
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
[MockProver] Testing is slower after #389 #398
Comments
Well that is not the direction we wanted the numbers to go! Suggests that the cost of constructing the |
There's a way to fix this by sorting in one pass rather than by inserting into a |
I can reproduce this regression (18.15s -> 48.88s on a Core i7-6800K @ 3.40GHz). |
If I stub out the lookup check as shown, the test takes 18.05s on the same machine. This implies that, at least for this experiment, the O(n2) part of the lookup check was only taking 0.1s overall, and was not the original performance problem. (It probably is a problem for larger tables, just not for the table size in this experiment.) diff --git a/src/dev.rs b/src/dev.rs
index e474232..7121e6a 100644
--- a/src/dev.rs
+++ b/src/dev.rs
@@ -713,7 +713,7 @@ impl<F: FieldExt> MockProver<F> {
// In the real prover, the lookup expressions are never enforced on
// unusable rows, due to the (1 - (l_last(X) + l_blind(X))) term.
- let table: std::collections::BTreeSet<Vec<_>> = self
+ let table: Vec<_> = self
.usable_rows
.clone()
.map(|table_row| {
@@ -730,7 +730,7 @@ impl<F: FieldExt> MockProver<F> {
.iter()
.map(|c| load(c, input_row))
.collect();
- let lookup_passes = table.contains(&inputs);
+ let lookup_passes = true;
if lookup_passes {
None
} else { |
I tried this but it only recovered part of the performance regression (23.96s on the experiment): diff --git a/src/dev.rs b/src/dev.rs
index e474232..6cf5d0b 100644
--- a/src/dev.rs
+++ b/src/dev.rs
@@ -713,7 +713,7 @@ impl<F: FieldExt> MockProver<F> {
// In the real prover, the lookup expressions are never enforced on
// unusable rows, due to the (1 - (l_last(X) + l_blind(X))) term.
- let table: std::collections::BTreeSet<Vec<_>> = self
+ let mut table: Vec<_> = self
.usable_rows
.clone()
.map(|table_row| {
@@ -724,13 +724,15 @@ impl<F: FieldExt> MockProver<F> {
.collect::<Vec<_>>()
})
.collect();
+ table.sort();
+
self.usable_rows.clone().filter_map(move |input_row| {
let inputs: Vec<_> = lookup
.input_expressions
.iter()
.map(|c| load(c, input_row))
.collect();
- let lookup_passes = table.contains(&inputs);
+ let lookup_passes = table.binary_search(&inputs).is_ok();
if lookup_passes {
None
} else { Merry Christmas! |
…ed in the table, fixing a performance regression. Includes an optimization for zero rows in the table. closes zcash#398 Signed-off-by: Daira Hopwood <daira@jacaranda.org>
@ChihChengLiang Please verify that this branch, based on your (This code has changed significantly upstream, so I'll have to reapply the change to main for that.) |
@daira I can verify the regression is fixed. I'm getting 12.00s, 11.45s, 11.40s on the 3 runs on your branch applied. That's very close to the 11.28s on the original branch with no change applied. Thank you so much for looking into this and the fix. |
Note that the branch https://github.com/daira/halo2/tree/mockprover-regression-appliedzkp has a bug that causes it to report the wrong row number for lookup failures, but that bug cannot affect performance. It's not present in #445 , but I thought I'd mention it in case you still need the earlier branch. |
Noted, thanks for the heads up :) |
are contained in the table, fixing a performance regression. This includes an optimization for "fill rows", which are assumed in this commit to be all-zeros. closes zcash#398 Signed-off-by: Daira Hopwood <daira@jacaranda.org>
Problem
The test speed is slower when #389 is applied.
We use the test of this branch for experiment privacy-scaling-explorations/zkevm-circuits#156
cargo test --release test_rho_gate -p keccak256 -- --nocapture
is about 11 sec on old commit4283713e
, but is about 34 sec on1723fed1
, which is4283713e
withgit cherry-pick b94aab76a338870fec778d4da3a1c6789bc92bc4
.The hardware is the apple M1 silicon.
Solution
Need investigation
The text was updated successfully, but these errors were encountered: