Bring stats for the method pool back.

llvm-svn: 110247
This commit is contained in:
Sebastian Redl 2010-08-04 21:22:45 +00:00
parent 31e90d2dd1
commit 6e1a2a0693
3 changed files with 29 additions and 16 deletions

View File

@ -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;

View File

@ -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<ObjCMethodList, ObjCMethodList>();
}

View File

@ -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.