Skip to content

Conversation

@nategraf
Copy link
Collaborator

@nategraf nategraf commented Oct 17, 2025

I did some profiling and iterated optimization on statement verification using the OONI benchmarks. The following changes result in ~40% reduction in verification time on my laptop.

  • Improve processing of constant terms by filtering out non-constant terms instead of using a zero weight.
  • Switch to using is_zero_vartime on public weight in process constraint.
  • Add a special case for one in get_or_create_weighted_group_var.
  • Avoid creating a map of reprs in canonical relation by assigning image points a var.

Breaking changes

  • CanonicalLinearRelation::image has a changed type from Vec<G> to Vec<GroupVar>.
  • serialization::serialize_elements now uses an impl IntoIterator signature for its argument. This should not effect any typical usage of this function (when a slice is passed in and the type of the fn is not directly asserted)

@nategraf nategraf requested a review from mmaker October 17, 2025 22:58

/// Access the group elements associated with the image (i.e. left-hand side), panicking if any
/// of the image variables are unassigned in the group mkap.
pub(crate) fn image_elems(&self) -> impl Iterator<Item = G> + use<'_, G> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometime we are using _elements, sometimes elems, let's call this elements for consistency

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2e2e00b

for elem_repr in group_elements_ordered {
out.extend_from_slice(elem_repr.as_ref());
// Dump the group elements.
for (_, elem) in self.group_elements.iter() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm here I'm noticing we're not using our API for serialization.
It's not a big deal, but it'd make the code more consistent + there's batch serialization formulae for elliptic curve implementation (relying on batch affine conversion) we might want to switch to that.

I don't think we need to change this now, but a placeholder would help

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can go ahead and change that. I didn't notice that when I made the change. This code is also just a lot simpler now. What I realized is that when I first wrote this, the work that is happening in TryFrom now was happening here (IIRC).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 4b2d80a and 22b8df7

@nategraf nategraf requested a review from mmaker October 21, 2025 02:46
@mmaker mmaker merged commit 5e35055 into main Oct 26, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants