Catch unwinds from the global ctxt callback to complete queries profiling data in more cases#155991
Open
lqd wants to merge 1 commit intorust-lang:mainfrom
Open
Catch unwinds from the global ctxt callback to complete queries profiling data in more cases#155991lqd wants to merge 1 commit intorust-lang:mainfrom
lqd wants to merge 1 commit intorust-lang:mainfrom
Conversation
…from queries fatal errors currently abort the compiler process without allocating the self-profile strings: query events aren't always correctly recorded, and will show up as <unknown> in the data. catching the unwinding panic allows us to finalize the self-profiling process correctly before continuing unwinding as before.
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.
The driver/compiler interface provides multiple callbacks, and we sometimes catch unwinds to flush diagnostics, ensure ICEs appear, and so on even when fatal errors occur.
When these panics happen, we don't
finishtheTyCtxt, and there's a fixme about that. Unfortunately this is where we also allocate the self-profile strings: query events for example start as virtual and are turned into real strings by this finalization process; they are invalid without this step. When fatal errors happen, the in-flight query name will be<unknown>, event counts will be inaccurate, etc.This PR catches panics from another of these callbacks, where the
TyCtxtis available, to allow for the self-profiling data to be computed before continuing the unwinding process as before.finishdoes more things, that I don't want to introduce here.I remember seeing this discussed in GH issues in the past, but can't find any open ones now. It may also have been only mentioned while trying to profile existing slowness issues. I stumbled upon this again recently when looking into
tests/ui/try-trait/deep-try-chain-issue-153583.rs, where the slowest query is<unknown>.This PR fixes that case at least. In general, it should fix the invalid profiling records for fatal errors happening while a query is running.
r? @bjorn3