Skip to content

Reference Counting for Circuit Arrays #1234

@JulianGCalderon

Description

@JulianGCalderon

Depends on #1233.

Each call to get_output involves calling dup on the circuit outputs. Right now, this implies cloning the entire array. We should implement a reference counting mechanism instead to avoid this.

let outputs = circuit_data
    .eval(modulus)
    .unwrap();

outputs.get_output(add2);
outputs.get_output(add2);
outputs.get_output(add2);
outputs.get_output(add2);
outputs.get_output(add2);

The reference counting would be quite simple:

  • On dup, increment the reference counter.
  • On drop, decrease the reference counter and free if last reference.

The reference counter should be shared between all instances, and therefore should be saved inside the allocation, like we do with regular arrays.

Q: How much code can be reused from the current array implementation?

Metadata

Metadata

Type

No type

Projects

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions