This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][NativePDB] Improve ParseDeclsForContext time.
ClosedPublic

Authored by zequanwu on Oct 14 2022, 5:29 PM.

Details

Summary
  1. When we evaluating an expression multiple times and the searching scope is translation unit, ParseDeclsForContext iterates the type info and symbol info multiple times, though only the debug info is parsed once. Using llvm::call_once to make it only iterating and parsing once.
  1. When evaluating an expression with identifier whose parent scope is a namespace, ParseDeclsForContext needs to search the entire type info to complete those records whose name is prefixed with the namespace's name and the entire symbol info to to parse functions and non-local variables. Caching parsed namespaces to avoid unnecessary searching.

Diff Detail

Event Timeline

zequanwu created this revision.Oct 14 2022, 5:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 5:29 PM
zequanwu requested review of this revision.Oct 14 2022, 5:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 5:29 PM
zequanwu retitled this revision from [LLDB][NativePDB] Fix ParseAllNamespacesPlusChildrenOf and avoid duplicate iteration on symbol stream to [LLDB][NativePDB] Improve ParseDeclsForContext time..Oct 17 2022, 4:41 PM
zequanwu edited the summary of this revision. (Show Details)
zequanwu added reviewers: labath, rnk.

Is this purely a performance optimization, or does it have some impact on operation (its correctness) as well? E.g. does it prevent duplicate construction of some types or something like that?

Is this purely a performance optimization, or does it have some impact on operation (its correctness) as well? E.g. does it prevent duplicate construction of some types or something like that?

It's purely a performance optimization. Avoid doing some unnecessary work.

labath accepted this revision.Oct 20 2022, 4:20 AM

Okay, sounds good then.

lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
1410–1412

I have a feeling this is still doing more work than it would be necessary. I haven't checked, but I'd expect that here it should be sufficient to parse only the top level namespace names (not their contents), and create forward declarations for the classes in the global namespace. I suspect this is doing much more than that.
(Of course, if PDB makes it hard to parse just this information, then it might actually be better to parse everything -- I just don't know)

This revision is now accepted and ready to land.Oct 20 2022, 4:20 AM
zequanwu updated this revision to Diff 469350.Oct 20 2022, 1:55 PM
zequanwu edited the summary of this revision. (Show Details)

Don't try to complete types in PdbAstBuilder::ParseDeclsForContext.

lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
1410–1412

Yeah, we can do that.
Update to don't try to complete types at all in PdbAstBuilder::ParseDeclsForContext. For a chrome crash report I'm looking at, the time for evaluating a unknown identifier(which will have search scope being a TU) drops from 287s -> 160s.

labath accepted this revision.Oct 21 2022, 5:58 AM
labath added inline comments.
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
1410–1412

cool

This revision was automatically updated to reflect the committed changes.