Repository navigation
Conversation
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
r? me |
Contributor
Author
|
@bors try jobs=test-x86_64-msvc-1 |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 16, 2026
[Debuginfo] Optimize MSVC enum visualizer try-job: test-x86_64-msvc-1
Contributor
This comment has been minimized.
This comment has been minimized.
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
jieyouxu
reviewed
Nov 20, 2026
This branch has not been deployed
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.
~10x's the performance of the msvc visualizers, even in conditions that aren't technically that bad. This change should have no user-facing affects aside from the speedup. Followup patch will apply the same to the gnu enum visualizers, though I suspect the speedup will be a bit smaller.
The following benchmarks were performed with this 3-variant enum definition, all times are in seconds:
Before:
After:
Problem
SyntheticProvider.update()is called by LLDB (more or less) whenever you interact with a variable, even if it hasn't changed. Re-requesting the same variable (e.g.v var) typically also invokes anupdatecall.The MSVC enum providers were doing quite a lot of work within
updateto determine which variant to use, since we have to iterate through each possible variant and trial-and-error check a bunch of statics. Additionally, due to a (slightly lazy, slightly required) decision I made when writing them originally, the summary provider would run the enum through the entire synthetic provider again, effectively doubling the number ofupdatecalls whenever the summary is printed.Since
updatewas effectivelyO(number_of_variants), printing frames or large vecs could be noticeably slow. That slowness comes up more often because of how common enums are. Enums with lots of variants could cause issues too.Solution
Since enum layouts don't change, there's no reason to traverse them more than once. While we could (and many providers do) handle this in
__init__, that would still mean we traverse enum layouts on everySBValueobject creation.Instead, this patch implements a global cache to store enum layouts (with considerations to make sure the cache doesn't get stale or leak memory, there's a fairly lengthy comment explaining the rationale there). After storing the enum layout, retrieving any given variant is, at worst, 2 dict lookups + a few int comparisons over a list that I'm 95% sure can't be more than length 1 anyway1.
cc @Kobzol @jieyouxu (this doesn't directly involve the test suite, but it's a somewhat complex change and y'all are probably the best equipped to review it 🥲)
Footnotes
it's a list of the "untagged" variants that are described by a range (i.e.
DISCR_BEGIN,DISCR_END). I don't think the compiler can output a type with more than one of these? At the very least, afaik LLDB relies on that being the case for their GNU handling since that just omits the discriminant entirely if a variant needs a range of values. In any case, I made it a list just to be safe, but realistically it should just be a single element to check if it can't find if the dict lookup fails. ↩