Thank you for sharing the proposal, but I’m not convinced that it would provide a significant performance improvement.
For B::C, it would require querying all entries of B and then all entries of C to cross-check, resulting in an O(num_B * num_C) complexity. This process would need to be done recursively for A vs. B and across the parent chain. I’m not sure if this approach would be any better than building a reverse mapping once. In any case, both methods seem to be much slower than the O(num_C) approach of DW_IDX_type_hash.
I think the bigger problem of template / simple / canonical names remain
In the hot path we encountered, the declaration context comes from the compiler generated Dwarf, not from human input (I’ve attached the performance trace of the hot path at the end). So, it involves comparing the compiler’s output declaration context with the compiler’s output in .debug_names, and there is no concern about canonical names in this context. I’m not sure if there’s a valid scenario for human input to trigger the hot path.
| --89.09%--SymbolFileDWARF::ResolveTypeUID(DWARFDIE const&, bool)
| SymbolFileDWARF::ResolveType(DWARFDIE const&, bool, bool)
| SymbolFileDWARF::GetTypeForDIE(DWARFDIE const&, bool)
| SymbolFileDWARF::ParseType(lldb_private::SymbolContext const&, DWARFDIE const&, bool*)
| DWARFASTParserClang::ParseTypeFromDWARF(lldb_private::SymbolContext const&, DWARFDIE const&, bool*)
| DWARFASTParserClang::ParseStructureLikeDIE(lldb_private::SymbolContext const&, DWARFDIE const&, ParsedDWARFTypeAttributes&)
| SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(DWARFDIE const&)
| SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(DWARFDIE const&)
| lldb_private::DebugNamesDWARFIndex::GetTypes(DWARFDeclContext const&, llvm::function_ref<bool (DWARFDIE)>)
| |
| --89.03%--lldb_private::DebugNamesDWARFIndex::ProcessEntry(llvm::DWARFDebugNames::Entry const&, llvm::function_ref<bool (DWARFDIE)>)
| |
| |--86.21%--SymbolFileDWARF::GetDIE(DIERef const&)
| | |
| | --86.20%--DWARFDebugInfo::GetDIE(DIERef const&)
| | DWARFUnit::GetDIE(unsigned long)
| | |
| | --86.20%--DWARFUnit::ExtractDIEsIfNeeded()
| | |
| | |--85.39%--DWARFUnit::ExtractDIEsRWLocked()