noir
noir copied to clipboard
Consider introducing `BrilligFunctionPointer` into ACIR
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
When we want to have ACIR functions, this might be a good way to do it too instead of inlining the ACIR into ACIR
Duplicate of #2936
This feels like something that can be handled with this general solution: https://github.com/noir-lang/noir/issues/4428
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.
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).
It just occurred to me that we should potentially still keep brillig and ACIR separated
Yup agreed