Skip to content

Add tracing spans to borrow tracker functions #4452

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Stypox
Copy link
Contributor

@Stypox Stypox commented Jul 7, 2025

I should have added tracing spans to all relevant functions in borrow_tracker/mod.rs. So e.g. I skipped simple constructors (e.g. new_ptr) and debugging stuff (give_pointer_debug_name and print_borrow_state). I didn't go deeper into the tree/stacked subfolders, as it seems like all calls to the borrow checkers pass through borrow_tracker/mod.rs (let me know if I'm wrong on this, or if you need some more specific statistics about the functions in the checkers implementations).

Here are two traces for ./tests/pass/hello.rs (the latter was obtained with -Zmiri-tree-borrows). The tracing spans still only account for ~40% of the total time, so I will have to investigate where the rest of the time is spent. trace-stacked-borrows.zip trace-tree-borrows.zip

This PR also adds an alternative enter_trace_span! that does not depend on the Machine trait (unlike rustc_const_eval::enter_trace_span!) and that instead relies on #[cfg(feature = "tracing")]. I can open a separate PR just with that commit if that's preferred.

@Stypox Stypox changed the title Add enter_trace_span! that checks #[cfg("tracing")] Add tracing spans to borrow tracker functions Jul 7, 2025
@@ -354,6 +363,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
&self,
frame: &Frame<'tcx, Provenance, FrameExtra<'tcx>>,
) -> InterpResult<'tcx> {
let _span = enter_trace_span!("on_stack_pop");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all these be called something like borrow_tracker::on_stack_pop or so? Just on_stack_pop is kind of unspecific.

Is there some way in the analysis tools to group all the borrow_tracker spans together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants