[cfe-commits] r125326 - /cfe/trunk/lib/Serialization/ASTWriter.cpp

Douglas Gregor dgregor at apple.com
Thu Feb 10 16:52:17 PST 2011


Author: dgregor
Date: Thu Feb 10 18:52:17 2011
New Revision: 125326

URL: http://llvm.org/viewvc/llvm-project?rev=125326&view=rev
Log:
Eliminate a major performance problem with chained PCH, where we were
causing the deserialization of a large number of declarations when
writing the visible-updates record for the translation unit in C. This
takes us from:

*** AST File Statistics:
  2 stat cache hits
  6 stat cache misses
  1/64463 source location entries read (0.001551%)
  15606/16956 types read (92.038216%)
  59266/89334 declarations read (66.342041%)
  38952/61393 identifiers read (63.446976%)
  0/7778 selectors read (0.000000%)
  24192/34644 statements read (69.830276%)
  388/8809 macros read (4.404586%)
  2095/5189 lexical declcontexts read (40.373867%)
  0/4587 visible declcontexts read (0.000000%)
  0/7716 method pool entries read (0.000000%)
  0 method pool misses

to

*** AST File Statistics:
  2 stat cache hits
  6 stat cache misses
  1/64463 source location entries read (0.001551%)
  26/16956 types read (0.153338%)
  18/89334 declarations read (0.020149%)
  145/61393 identifiers read (0.236183%)
  0/7778 selectors read (0.000000%)
  21/34644 statements read (0.060617%)
  0/8809 macros read (0.000000%)
  0/5189 lexical declcontexts read (0.000000%)
  0/4587 visible declcontexts read (0.000000%)
  0/7716 method pool entries read (0.000000%)
  0 method pool misses

when generating a chained PCH for a header that #includes Cocoa.h
(from a PCH file) and adds one simple function declaration. The
generated PCH file is now only 9580 bytes (down from > 2MB).

Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=125326&r1=125325&r2=125326&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Feb 10 18:52:17 2011
@@ -2475,10 +2475,6 @@
 /// DeclContext in a dependent AST file. As such, they only exist for the TU
 /// (in C++) and for namespaces.
 void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) {
-  // Make the context build its lookup table, but don't make it load external
-  // decls.
-  DC->lookup(DeclarationName());
-
   StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(DC->getLookupPtr());
   if (!Map || Map->empty())
     return;





More information about the cfe-commits mailing list