From 95fb36ebddcbdcd6b801c5d3d2d85dac315b4127 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 28 Jan 2013 17:54:36 +0000 Subject: [PATCH] Add some more ASTReader statistics for global method pool lookups. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173702 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Serialization/ASTReader.h | 18 ++++++++++++--- lib/Serialization/ASTReader.cpp | 30 +++++++++++++++++++------ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 7d4aa83b81..2dd698ed5c 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -549,7 +549,7 @@ private: GlobalSelectorMapType; /// \brief Mapping from global selector IDs to the module in which the - /// selector resides along with the offset that should be added to the + /// global selector ID to produce a local ID. GlobalSelectorMapType GlobalSelectorMap; @@ -752,8 +752,20 @@ private: unsigned NumMethodPoolEntriesRead; /// \brief The number of times we have looked up a selector in the method - /// pool and not found anything interesting. - unsigned NumMethodPoolMisses; + /// pool. + unsigned NumMethodPoolLookups; + + /// \brief The number of times we have looked up a selector in the method + /// pool and found something. + unsigned NumMethodPoolHits; + + /// \brief The number of times we have looked up a selector in the method + /// pool within a specific module. + unsigned NumMethodPoolTableLookups; + + /// \brief The number of times we have looked up a selector in the method + /// pool within a specific module and found something. + unsigned NumMethodPoolTableHits; /// \brief The total number of method pool entries in the selector table. unsigned TotalNumMethodPoolEntries; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 0261ad8f48..8a8f6a2cfe 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -5655,8 +5655,19 @@ void ASTReader::PrintStats() { NumMethodPoolEntriesRead, TotalNumMethodPoolEntries, ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries * 100)); - std::fprintf(stderr, " %u method pool misses\n", NumMethodPoolMisses); } + if (NumMethodPoolLookups) { + std::fprintf(stderr, " %u/%u method pool lookups succeeded (%f%%)\n", + NumMethodPoolHits, NumMethodPoolLookups, + ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0)); + } + if (NumMethodPoolTableLookups) { + std::fprintf(stderr, " %u/%u method pool table lookups succeeded (%f%%)\n", + NumMethodPoolTableHits, NumMethodPoolTableLookups, + ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups + * 100.0)); + } + if (NumIdentifierLookupHits) { std::fprintf(stderr, " %u / %u identifier table lookups succeeded (%f%%)\n", @@ -5872,12 +5883,14 @@ namespace clang { namespace serialization { if (M.Generation <= This->PriorGeneration) return true; + ++This->Reader.NumMethodPoolTableLookups; ASTSelectorLookupTable *PoolTable = (ASTSelectorLookupTable*)M.SelectorLookupTable; ASTSelectorLookupTable::iterator Pos = PoolTable->find(This->Sel); if (Pos == PoolTable->end()) return false; - + + ++This->Reader.NumMethodPoolTableHits; ++This->Reader.NumSelectorsRead; // FIXME: Not quite happy with the statistics here. We probably should // disable this tracking when called via LoadSelector. @@ -5920,15 +5933,16 @@ void ASTReader::ReadMethodPool(Selector Sel) { Generation = CurrentGeneration; // Search for methods defined with this selector. + ++NumMethodPoolLookups; ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration); ModuleMgr.visit(&ReadMethodPoolVisitor::visit, &Visitor); if (Visitor.getInstanceMethods().empty() && - Visitor.getFactoryMethods().empty()) { - ++NumMethodPoolMisses; + Visitor.getFactoryMethods().empty()) return; - } - + + ++NumMethodPoolHits; + if (!getSema()) return; @@ -7038,7 +7052,9 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context, NumStatementsRead(0), TotalNumStatements(0), NumMacrosRead(0), TotalNumMacros(0), NumIdentifierLookups(0), NumIdentifierLookupHits(0), NumSelectorsRead(0), NumMethodPoolEntriesRead(0), - NumMethodPoolMisses(0), TotalNumMethodPoolEntries(0), + NumMethodPoolLookups(0), NumMethodPoolHits(0), + NumMethodPoolTableLookups(0), NumMethodPoolTableHits(0), + TotalNumMethodPoolEntries(0), NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0), TotalModulesSizeInBits(0), NumCurrentElementsDeserializing(0), -- 2.40.0