-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move witness computation into class plus some other cleanup (#…
…11140) Minor cleanup/refactor of Flavor logic (particularly MegaFlavor). Mostly deleting unused methods and moving that did not strictly belong in the Flavor to new classes `WitnessComputation` and `MegaMemoryEstimator`
- Loading branch information
1 parent
80ec19e
commit d41e9ab
Showing
14 changed files
with
274 additions
and
303 deletions.
There are no files selected for viewing
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
77 changes: 77 additions & 0 deletions
77
barretenberg/cpp/src/barretenberg/benchmark/mega_memory_bench/memory_estimator.hpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#pragma once | ||
|
||
#include "barretenberg/stdlib_circuit_builders/mega_flavor.hpp" | ||
#include <cstdint> | ||
|
||
namespace bb { | ||
|
||
/** | ||
* @brief Methods for estimating memory in key components of MegaHonk | ||
* | ||
*/ | ||
class MegaMemoryEstimator { | ||
using FF = MegaFlavor::FF; | ||
|
||
public: | ||
static uint64_t estimate_proving_key_memory(MegaFlavor::ProvingKey& proving_key) | ||
{ | ||
vinfo("++Estimating proving key memory++"); | ||
|
||
auto& polynomials = proving_key.polynomials; | ||
|
||
for (auto [polynomial, label] : zip_view(polynomials.get_all(), polynomials.get_labels())) { | ||
uint64_t size = polynomial.size(); | ||
vinfo(label, " num: ", size, " size: ", (size * sizeof(FF)) >> 10, " KiB"); | ||
} | ||
|
||
uint64_t result(0); | ||
for (auto& polynomial : polynomials.get_unshifted()) { | ||
result += polynomial.size() * sizeof(FF); | ||
} | ||
|
||
result += proving_key.public_inputs.capacity() * sizeof(FF); | ||
|
||
return result; | ||
} | ||
|
||
static uint64_t estimate_builder_memory(MegaFlavor::CircuitBuilder& builder) | ||
{ | ||
vinfo("++Estimating builder memory++"); | ||
uint64_t result{ 0 }; | ||
|
||
// gates: | ||
for (auto [block, label] : zip_view(builder.blocks.get(), builder.blocks.get_labels())) { | ||
uint64_t size{ 0 }; | ||
for (const auto& wire : block.wires) { | ||
size += wire.capacity() * sizeof(uint32_t); | ||
} | ||
for (const auto& selector : block.selectors) { | ||
size += selector.capacity() * sizeof(FF); | ||
} | ||
vinfo(label, " size ", size >> 10, " KiB"); | ||
result += size; | ||
} | ||
|
||
// variables | ||
size_t to_add{ builder.variables.capacity() * sizeof(FF) }; | ||
result += to_add; | ||
vinfo("variables: ", to_add); | ||
|
||
// public inputs | ||
to_add = builder.public_inputs.capacity() * sizeof(uint32_t); | ||
result += to_add; | ||
vinfo("public inputs: ", to_add); | ||
|
||
// other variable indices | ||
to_add = builder.next_var_index.capacity() * sizeof(uint32_t); | ||
to_add += builder.prev_var_index.capacity() * sizeof(uint32_t); | ||
to_add += builder.real_variable_index.capacity() * sizeof(uint32_t); | ||
to_add += builder.real_variable_tags.capacity() * sizeof(uint32_t); | ||
result += to_add; | ||
vinfo("variable indices: ", to_add); | ||
|
||
return result; | ||
} | ||
}; | ||
|
||
} // namespace bb |
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
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
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
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
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
Oops, something went wrong.
d41e9ab
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.
Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.wasmClientIVCBench/Full/6
81710.988247
ms/iter72335.739343
ms/iter1.13
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ludamad @codygunton