chore: replace asserts with runtime errors.#15671
Conversation
|
Once the change is ready, we should also benchmark it to make sure that its effect on performance is negligible. |
eee30d8 to
40c665a
Compare
| , current_max(current_max) | ||
| { | ||
| ASSERT(safety == IS_UNSAFE); | ||
| if (current_max > MAX_VALUE) // For optimal efficiency this should only be checked while testing a circuit |
There was a problem hiding this comment.
Not sure what it means by "testing a circuit". Looks like it's already checked in release builds anyway?
| BB_ASSERT_EQ(challenge_poly.evaluate(opening_pair.challenge), opening_pair.evaluation, "Opening claim does not hold for challenge polynomial."); | ||
| BB_ASSERT_EQ_DEBUG_ONLY(challenge_poly.evaluate(opening_pair.challenge), opening_pair.evaluation, "Opening claim does not hold for challenge polynomial."); | ||
|
|
||
| IPA<NativeCurve, log_poly_length>::compute_opening_proof(ck, { challenge_poly, opening_pair }, prover_transcript); | ||
| BB_ASSERT_EQ(challenge_poly.evaluate(fq(output_claim.opening_pair.challenge.get_value())), fq(output_claim.opening_pair.evaluation.get_value()), "Opening claim does not hold for challenge polynomial."); | ||
| BB_ASSERT_EQ_DEBUG_ONLY(challenge_poly.evaluate(fq(output_claim.opening_pair.challenge.get_value())), fq(output_claim.opening_pair.evaluation.get_value()), "Opening claim does not hold for challenge polynomial."); |
There was a problem hiding this comment.
Are these evaluations potentially heavy?
There was a problem hiding this comment.
the debugging gains might outstrip how long it takes - tbh we can probably just add TODOs around anything we really think is heavy, I don't think I saw anything egregious stand out
04d3335 to
66b1003
Compare
| current_max, MAX_VALUE, "exceeded modulus in safe_uint class"); // For optimal efficiency this should only | ||
| // be checked while testing a circuit |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
Performance on Merge TrainBranch |
|
LGTM, thanks for doing this. I think I still would prefer just calling it ASSERT as it was before and having an ASSERT_DEBUG. for slow asserts. it can be in a follow-on if desired |
up to nullifier_tree.cpp up to bitvector.hpp constexpr noexcept up to evaluation_domain.cpp up to part of bigfield_impl.hpp up to part of safe_uint.hpp BB_ASSERT_EQ(poly.evalueate()) remove debug only BB_ASSERT except EQ fix build always include throw_or_abort in assert.hpp fix blake3 test fix tests remove debug checks in tests small fixes Remove unnecessary includes assert in constexpr remove BB_ASSERT_EQ_DEBUG_ONLY
0856a8b to
92fe1c3
Compare
The original names are fine. I messaged the crypto-dev channel to make sure people are aware of the change. |
|
I meant just calling it |
See [merge-train-readme.md](https://github.com/AztecProtocol/aztec-packages/blob/next/.github/workflows/merge-train-readme.md). BEGIN_COMMIT_OVERRIDE chore!: Remove circuit_size from all VKs (#15747) chore: Introduce data structures to hold inputs/outputs of the Merge verification (#15735) chore: replace asserts with runtime errors. (#15671) chore: kernels start with eq and reset (#15734) chore: Introduce Native IO mechanism (#15820) fix: Update Cargo.lock in avm-transpiler (#15837) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: ledwards2225 <98505400+ledwards2225@users.noreply.github.com> Co-authored-by: federicobarbacovi <171914500+federicobarbacovi@users.noreply.github.com> Co-authored-by: sergei iakovenko <105737703+iakovenkos@users.noreply.github.com> Co-authored-by: ludamad <adam.domurad@gmail.com> Co-authored-by: Suyash Bagad <suyash@aztecprotocol.com> Co-authored-by: Jonathan Hao <jonathan@aztec-labs.com> Co-authored-by: Raju Krishnamoorthy <krishnamoorthy@gmail.com> Co-authored-by: notnotraju <raju@aztec-labs.com> Co-authored-by: Lucas Xia <lucasxia01@gmail.com> Co-authored-by: Khashayar Barooti <khashayar@aztecprotocol.com> Co-authored-by: Jean M <132435771+jeanmon@users.noreply.github.com> Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com> Co-authored-by: Santiago Palladino <spalladino@users.noreply.github.com> Co-authored-by: Santiago Palladino <santiago@aztec-labs.com> Co-authored-by: ludamad <domuradical@gmail.com> Co-authored-by: maramihali <mara@aztecprotocol.com> Co-authored-by: Sarkoxed <75146596+Sarkoxed@users.noreply.github.com>
|
Adding some more benchmark results. It looks like on native the runtime is ~1% slower and on wasm it's ~5.5% slower. Benchmark 1: WASM 16 threadsRan on the benchmark machine via This branch:
Base branch (79ffdbc):
Benchmark 2: Native 192 threadsRan on the benchmark machine via This branch:
Base branch (79ffdbc):
|
#15671 regressed wasm performance by 5.5%, so this PR disables them in wasm. Ran on the benchmark machine via `scripts/benchmark_remote.sh client_ivc_bench '/bin/time -v ../scripts/wasmtime.sh client_ivc_bench --benchmark_filter=ClientIVCBench/Full/6' wasm-threads build-wasm-threads` This branch: | Runtime | Peak Memory | | --- | --- | | 80,501 ms | 2,868,200 kbs | | 80,092 ms | 2,290,660 kbs | | 79,490 ms | 2,290,560 kbs | Merge train: | Runtime | Peak Memory | | --- | --- | | 85,167 ms | 2,839,172 kbs | | 85,105 ms | 2,291,284 kbs | | 84,510 ms | 2,291,548 kbs |
BB_ASSERT_*now throw_or_abort in non-debug builds.ASSERTin tests withASSERT_TRUEor other gtest functions.EXPECT_DEATHandASSERT_DEATHin tests withEXPECT_THROW_OR_ABORTorASSERT_THROW_OR_ABORT.#ifdef NDEBUGaround the above in tests since they work in non-debug builds now.constexprs uses info instead of sstream.Fixes AztecProtocol/barretenberg#1460