noir icon indicating copy to clipboard operation
noir copied to clipboard

Consider introducing `BrilligFunctionPointer` into ACIR

Open kevaundray opened this issue 1 year ago • 4 comments

Problem

Currently we inline the bytecode into ACIR for each ACIR call.

A brillig opcode in ACIR will therefore contain the bytecode to be executed. This is a problem because if the same Brillig function is called N times, we will be duplicating the bytecode for that function N times.

Happy Case

We can store the bytecode in an ordered set and replace the bytecode for Brillig in the ACIR opcode, with a pointer to that ordered set.

If the same function is called multiple times, we only duplicate the pointer/index to the ordered set.

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

kevaundray avatar Dec 21 '23 18:12 kevaundray

When we want to have ACIR functions, this might be a good way to do it too instead of inlining the ACIR into ACIR

kevaundray avatar Dec 21 '23 18:12 kevaundray

Duplicate of #2936

TomAFrench avatar Dec 22 '23 14:12 TomAFrench

This feels like something that can be handled with this general solution: https://github.com/noir-lang/noir/issues/4428

vezenovm avatar Mar 04 '24 16:03 vezenovm

Agreed, I'm going to assign this to you and we can close it at the same time as when we handle the folding case.

TomAFrench avatar Mar 06 '24 12:03 TomAFrench

It just occurred to me that we should potentially still keep brillig and ACIR separated to resolve this rather than just treating them as circuits with a single Brillig opcode in them. Reason for this being that then have the backend completely ignore the brillig entirely and treat it as a binary blob as it doesn't need to understand it at all which should help speed up deserialization on the backend (or make it easier to strip them out before sending it to the backend).

TomAFrench avatar Apr 08 '24 18:04 TomAFrench

It just occurred to me that we should potentially still keep brillig and ACIR separated

Yup agreed

vezenovm avatar Apr 08 '24 18:04 vezenovm