Add TRACING_ENABLED to Machine and add enter_trace_span!()#140972
Merged
bors merged 2 commits intorust-lang:masterfrom May 21, 2025
Merged
Add TRACING_ENABLED to Machine and add enter_trace_span!()#140972bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
af8f491 to
7261a79
Compare
RalfJung
reviewed
May 20, 2025
Member
There was a problem hiding this comment.
I don't think we need a new module for that -- please just put this into the existing util module.
Contributor
Author
There was a problem hiding this comment.
Done and force-pushed
Member
|
@rustbot author Given how simple this PR is, feel free to just amend and force-push, so that we avoid another round-trip for a final squash. |
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
7261a79 to
28db348
Compare
Member
|
Please remember to |
Member
|
LGTM, thanks! |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 20, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#140972 (Add TRACING_ENABLED to Machine and add enter_trace_span!()) - rust-lang#141282 (`core_float_math`: Move functions to `math` module) - rust-lang#141288 (Get rid of unnecessary `BufDisplay` abstraction) - rust-lang#141289 (use `Self` alias in self types rather than manually substituting it) - rust-lang#141291 (link tracking issue in explicit-extern-abis.md) - rust-lang#141294 (triagebot: ping me if rustdoc js is modified) - rust-lang#141303 (Fix pagetoc inactive color in rustc book) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 21, 2025
Rollup merge of rust-lang#140972 - Stypox:machine-tracing-flag, r=RalfJung Add TRACING_ENABLED to Machine and add enter_trace_span!() 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: ```rs let _guard = enter_trace_span!(M, "eval_statement", "{:?}", stmt); ``` r? `@RalfJung`
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jun 11, 2025
…fJung Fix enter_trace_span!() using wrong $crate paths This is a followup to rust-lang#140972, where I made a silly mistake and forgot to update `$crate::interpret::tracing_utils::...` to `$crate::interpret::util::...` inside the macro after moving the referenced code from `tracing_utils.rs` to `util.rs`. Sorry about this. r? `@RalfJung`
rust-timer
added a commit
that referenced
this pull request
Jun 12, 2025
Rollup merge of #142356 - Stypox:fix-enter_trace_span, r=RalfJung Fix enter_trace_span!() using wrong $crate paths This is a followup to #140972, where I made a silly mistake and forgot to update `$crate::interpret::tracing_utils::...` to `$crate::interpret::util::...` inside the macro after moving the referenced code from `tracing_utils.rs` to `util.rs`. Sorry about this. r? `@RalfJung`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the necessary infrastructure to make it possible to do tracing calls from within
rustc_const_evalwhen running Miri, while making sure they don't impact the performance of normal compiler execution. This is done by adding aconstboolean toMachine, false by default, but that will be set to true in Miri only. The tracing macroenter_trace_span!()checks if it is true before doing anything, and since the value of aconstis 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:
r? @RalfJung