Skip to content

Add TRACING_ENABLED to Machine and add enter_trace_span!() #140972

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 May 13, 2025

This PR adds the necessary infrastructure to make it possible to do tracing calls from within rustc_const_eval when running Miri, while making sure they don't impact the performance of normal compiler execution. This is done by adding a const boolean to Machine, false by default, but that will be set to true in Miri only. The tracing macro enter_trace_span!() checks if it is true before doing anything, and since the value of a const is known at compile time, if it it false it the whole tracing call should be optimized out.

I will soon open further PRs to add tracing macro calls similar to this one, so that afterwards it will be possible to learn more about Miri's time spent in the various interpretation steps:

let _guard = enter_trace_span!(M, "eval_statement", "{:?}", stmt);

r? @RalfJung

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 13, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@Stypox Stypox force-pushed the machine-tracing-flag branch from af8f491 to 7261a79 Compare May 13, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants