algebra icon indicating copy to clipboard operation
algebra copied to clipboard

Instrument field operations

Open WizardOfMenlo opened this issue 1 year ago • 3 comments

Especially when prototyping a new protocol, having a accurate field operation counts is very important. My proposal would be to add this behind a feature flag, adding a globally accessible stats counter that is then updated. Ideally, by turning on the instrumentation flag, the user would be able to transparently instrument their code with no changes required.

WizardOfMenlo avatar Dec 28 '23 11:12 WizardOfMenlo

You'd typically count curve operations plus FFTs.

You could've curve+field forks or wrapper types, which achieved this. If you only want curve operations, then you could check out https://github.com/paritytech/arkworks-extensions

If you opnly want curve operations, then you could integrate this approch with different benchmarking tools.

burdges avatar Dec 29 '23 20:12 burdges

For my particular use-case, curve operations and FFTs are not too relevant. I really would just want to be able to count the number of field additions, multiplications and divisions. I assume that, once that is done the common infrastructure could be extended to other functionalities. Possibly we could decorate methods which should (optionally) be instrumented with some derive_macro which writes to a common (global, thread safe, possibly slow) counter. Then, on the counter itself we can implement some aggregation for better user functionality.

WizardOfMenlo avatar Dec 30 '23 00:12 WizardOfMenlo

Above, we targeted the expensive operations above, without changing the fields, but..

It's likely easier to just count field operations, either cargo patch in your fork of ark-ff, or else simply fork the curve with one commit that sustitutes your ark-ff.

burdges avatar Dec 30 '23 01:12 burdges