-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: location tree for debug_info #7034
base: master
Are you sure you want to change the base?
Conversation
Compilation Memory Report
|
Execution Memory Report
|
Execution Report
|
Compilation Report
|
Merging in master to compare artifact sizes in aztec-packages. |
Nice, this drops the artifact size of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to hit send on these comments.
Also aztec-packages has their own homebrew method of dealing with debug info in their simulator which is this is definitely going to break. Can you take a look at what this will take to update?
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs
Outdated
Show resolved
Hide resolved
pub brillig_locations: | ||
BTreeMap<BrilligFunctionId, BTreeMap<BrilligOpcodeLocation, CallStackId>>, | ||
pub location_tree: LocationTree, | ||
/// Map opcode index of an ACIR circuit into the source code location | ||
/// Serde does not support mapping keys being enums for json, so we indicate | ||
/// that they should be serialized to/from strings. | ||
#[serde_as(as = "BTreeMap<DisplayFromStr, _>")] | ||
pub locations: BTreeMap<OpcodeLocation, Vec<Location>>, | ||
pub brillig_locations: | ||
BTreeMap<BrilligFunctionId, BTreeMap<BrilligOpcodeLocation, Vec<Location>>>, | ||
pub location_map: BTreeMap<OpcodeLocation, CallStackId>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an explainer on how exactly these fit together? I'm thinking that we're storing unnecessary data in location_map
now.
My understanding is that:
brillig_locations
stores for each brillig function a mapping from each opcode index to a callstack id- We can then use this and then look up the callstack id in
location_tree
to get the associate callstack for any brillig opcode. location_map
stores a mapping from(acir_opcode_index, brillig_index)
to a callstack id which we can use withlocation_tree
.
Why do we need to track (acir_opcode_index, brillig_index)
in location_map
now? If we fail inside of a brillig call we can tell which brillig function we're executing from the ACIR opcode we've halted on, we then
- Get the callstack for the ACIR opcode in which we make the call
- Check the brillig opcode within that call we halted on and get the relevant callstack for the unconstrained function.
- Smoosh these two together to generate the final callstack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this makes sense, in practice I don't see where those brillig locations are inserted in the location_map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, true we seem to have removed the insertion of any OpcodeLocation::Brillig
a while back.
It still stands that we don't need to keep this enum in the build artifact anymore though as it's currently tech debt. We've kept this enum around just to keep the program serialization format the same but as we're changing it now anyway, now's a good time to clear up this tech debt.
noir/acvm-repo/acir/src/circuit/mod.rs
Lines 139 to 147 in 0512ee6
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] | |
/// Opcodes are locatable so that callers can | |
/// map opcodes to debug information related to their context. | |
pub enum OpcodeLocation { | |
Acir(usize), | |
// TODO(https://github.com/noir-lang/noir/issues/5792): We can not get rid of this enum field entirely just yet as this format is still | |
// used for resolving assert messages which is a breaking serialization change. | |
Brillig { acir_index: usize, brillig_index: usize }, | |
} |
Description
Problem*
Resolves #6946
Summary*
Adds the location tree to debug info and reference call-stacks through their 'index' in the tree (i.e a node of the tree).
Additional Context
The location tree is merged from ACIR location tree and brillig per function location trees.
The PR is a draft because it does not merge the trees in case of several ACIR functions, and also one flame graph test is failing in Noir debugger.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.