
I tried to run llvm-pdbdump on a very large (~1.5GB) PDB to try and identify show-stopping performance problems. This patch addresses the first such problem. When loading the DBI stream, before anyone has even tried to access a single record, we build an in memory map of every source file for every module. In the particular PDB I was using, this was over 85 million files. Specifically, the complexity is O(m*n) where m is the number of modules and n is the average number of source files (including headers) per module. The whole reason for doing this was so that we could have constant time access to any module and any of its source file lists. However, we can still get O(1) access to the source file list for a given module with a simple O(m) precomputation, and access to the list of modules is already O(1) anyway. So this patches reduces the O(m*n) up-front precomputation to an O(m) one, where n is ~6,500 and n*m is about 85 million in my pathological test case. Differential Revision: https://reviews.llvm.org/D32870 llvm-svn: 302205
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
//==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- C++ -*-==//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
|
|
|
|
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
|
#include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
|
|
#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
|
|
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
|
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
|
|
|
|
namespace llvm {
|
|
namespace pdb {
|
|
|
|
NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
|
|
const DbiModuleList &Modules,
|
|
uint32_t Index)
|
|
: Session(PDBSession), Modules(Modules), Index(Index) {}
|
|
|
|
uint32_t NativeEnumModules::getChildCount() const {
|
|
return static_cast<uint32_t>(Modules.getModuleCount());
|
|
}
|
|
|
|
std::unique_ptr<PDBSymbol>
|
|
NativeEnumModules::getChildAtIndex(uint32_t Index) const {
|
|
if (Index >= Modules.getModuleCount())
|
|
return nullptr;
|
|
return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(
|
|
Session, std::unique_ptr<IPDBRawSymbol>(new NativeCompilandSymbol(
|
|
Session, Modules.getModuleDescriptor(Index)))));
|
|
}
|
|
|
|
std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
|
|
if (Index >= Modules.getModuleCount())
|
|
return nullptr;
|
|
return getChildAtIndex(Index++);
|
|
}
|
|
|
|
void NativeEnumModules::reset() { Index = 0; }
|
|
|
|
NativeEnumModules *NativeEnumModules::clone() const {
|
|
return new NativeEnumModules(Session, Modules, Index);
|
|
}
|
|
|
|
}
|
|
}
|