arkworks-rs / snark

Interfaces for Relations and SNARKs for these relations
https://www.arkworks.rs
Apache License 2.0
776 stars 209 forks source link

Use `#[track_caller]` to make automated namespacing useful #250

Closed Pratyush closed 4 years ago

Pratyush commented 4 years ago

In the new refactor of the ConstraintSystem API, one doesn't have to thread &mut cs.ns(|| "new namespace") everywhere. While this enables lots of improvements, such as overloading arithmetic operators for field and group variables, the lack of meaningful human annotated names does cause a regression in diagnostics, debugging, and profiling.

The current approach would be to do manual annotations using the cs.ns() API, and this provides some high level information, but for most profiling/debugging use cases, but this doesn't suffice. A better way would be automatically annotate the relevant namespaces with file, line number and column information using the Location API in combination with #[track_caller]

Pratyush commented 4 years ago

This doesn't actually work because the track_caller only returns the location of one location in the call stack, and does not return the path in the namespace tree. TO fix this, I moved to a tracing-based profiling infrastructure in #270 .