Several frequently used methods in libsnark::protoboard return by value rather than by reference, this copies all of the data every time they're called:
It is unnecessary to perform a full copy of any of this data, and with very large constraint systems there's a significant overhead introduced by the copy constructor.
An alternative would be to change the visibility of properties of libsnark::protoboard from private to public or protected. This is the least-effort solution which requires no changes to dependent code.
I will check which one is the best option, and submit a pull request. 👍
Instigated from: https://github.com/HarryR/ethsnarks/issues/99
Several frequently used methods in
libsnark::protoboard
return by value rather than by reference, this copies all of the data every time they're called:r1cs_variable_assignment<FieldT> full_variable_assignment() const;
r1cs_primary_input<FieldT> primary_input() const;
r1cs_auxiliary_input<FieldT> auxiliary_input() const;
r1cs_constraint_system<FieldT> get_constraint_system() const;
It is unnecessary to perform a full copy of any of this data, and with very large constraint systems there's a significant overhead introduced by the copy constructor.
I will verify whether these can be changed to:
const r1cs_variable_assignment<FieldT>& full_variable_assignment() const;
const r1cs_primary_input<FieldT>& primary_input() const;
const r1cs_auxiliary_input<FieldT>& auxiliary_input() const;
const r1cs_constraint_system<FieldT>& get_constraint_system() const;
An alternative would be to change the visibility of properties of
libsnark::protoboard
fromprivate
topublic
orprotected
. This is the least-effort solution which requires no changes to dependent code.I will check which one is the best option, and submit a pull request. 👍