From fa78dec572259aca763457b435744f79d822c5d4 Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Wed, 4 Aug 2010 21:22:45 +0000 Subject: [PATCH] Bring stats for the method pool back. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110247 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Frontend/PCHReader.h | 16 +++++++++++----- lib/Frontend/PCHReader.cpp | 25 +++++++++++++++---------- lib/Frontend/PCHWriter.cpp | 4 +++- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h index c49e8a195a..f7690fbb21 100644 --- a/include/clang/Frontend/PCHReader.h +++ b/include/clang/Frontend/PCHReader.h @@ -459,15 +459,21 @@ private: /// \brief The number of macros de-serialized from the PCH file. unsigned NumMacrosRead; + /// \brief The total number of macros stored in the PCH file. + unsigned TotalNumMacros; + /// \brief The number of selectors that have been read. unsigned NumSelectorsRead; - /// \brief The number of times we have looked into the selector table - /// and not found anything. - unsigned NumSelectorMisses; + /// \brief The number of method pool entries that have been read. + unsigned NumMethodPoolEntriesRead; - /// \brief The total number of macros stored in the PCH file. - unsigned TotalNumMacros; + /// \brief The number of times we have looked up a selector in the method + /// pool and not found anything interesting. + unsigned NumMethodPoolMisses; + + /// \brief The total number of method pool entries in the selector table. + unsigned TotalNumMethodPoolEntries; /// Number of lexical decl contexts read/total. unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index ffc12cc729..2252fd4729 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -421,8 +421,9 @@ PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context, Consumer(0), isysroot(isysroot), DisableValidation(DisableValidation), NumStatHits(0), NumStatMisses(0), NumSLocEntriesRead(0), TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0), - NumMacrosRead(0), NumSelectorsRead(0), NumSelectorMisses(0), - TotalNumMacros(0), NumLexicalDeclContextsRead(0), + NumMacrosRead(0), TotalNumMacros(0), NumSelectorsRead(0), + NumMethodPoolEntriesRead(0), NumMethodPoolMisses(0), + TotalNumMethodPoolEntries(0), NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0) { RelocatablePCH = false; @@ -436,7 +437,8 @@ PCHReader::PCHReader(SourceManager &SourceMgr, FileManager &FileMgr, isysroot(isysroot), DisableValidation(DisableValidation), NumStatHits(0), NumStatMisses(0), NumSLocEntriesRead(0), TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0), NumMacrosRead(0), - NumSelectorsRead(0), NumSelectorMisses(0), TotalNumMacros(0), + TotalNumMacros(0), NumSelectorsRead(0), NumMethodPoolEntriesRead(0), + NumMethodPoolMisses(0), TotalNumMethodPoolEntries(0), NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0) { @@ -1662,6 +1664,7 @@ PCHReader::ReadPCHBlock(PerFileData &F) { F.SelectorLookupTableData + Record[0], F.SelectorLookupTableData, PCHSelectorLookupTrait(*this)); + TotalNumMethodPoolEntries += Record[1]; break; case pch::REFERENCED_SELECTOR_POOL: { @@ -3092,15 +3095,13 @@ void PCHReader::PrintStats() { NumVisibleDeclContextsRead, TotalVisibleDeclContexts, ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts * 100)); -#if 0 - if (TotalSelectorsInSelector) { + if (TotalNumMethodPoolEntries) { std::fprintf(stderr, " %u/%u method pool entries read (%f%%)\n", - NumSelectorSelectorsRead, TotalSelectorsInSelector, - ((float)NumSelectorSelectorsRead/TotalSelectorsInSelector + NumMethodPoolEntriesRead, TotalNumMethodPoolEntries, + ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries * 100)); - std::fprintf(stderr, " %u method pool misses\n", NumSelectorMisses); + std::fprintf(stderr, " %u method pool misses\n", NumMethodPoolMisses); } -#endif std::fprintf(stderr, "\n"); } @@ -3222,6 +3223,10 @@ PCHReader::ReadMethodPool(Selector Sel) { PCHSelectorLookupTable::iterator Pos = PoolTable->find(Sel); if (Pos != PoolTable->end()) { ++NumSelectorsRead; + // FIXME: Not quite happy with the statistics here. We probably should + // disable this tracking when called via LoadSelector. + // Also, should entries without methods count as misses? + ++NumMethodPoolEntriesRead; PCHSelectorLookupTrait::data_type Data = *Pos; if (DeserializationListener) DeserializationListener->SelectorRead(Data.ID, Sel); @@ -3229,7 +3234,7 @@ PCHReader::ReadMethodPool(Selector Sel) { } } - ++NumSelectorMisses; + ++NumMethodPoolMisses; return std::pair(); } diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 06f64431d8..53c05c8fdf 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1694,9 +1694,11 @@ void PCHWriter::WriteSelectors(Sema &SemaRef) { } if (!changed) continue; + } else if (Data.Instance.Method || Data.Factory.Method) { + // A new method pool entry. + ++NumTableEntries; } Generator.insert(S, Data); - ++NumTableEntries; } // Create the on-disk hash table in a buffer. -- 2.40.0