Author: benlangmuir
Date: Fri Apr 10 17:25:42 2015
New Revision: 234655

URL: http://llvm.org/viewvc/llvm-project?rev=234655&view=rev
Log:
Workaround a performance issue with modules + PCH

More fallout from r228234; when looking up an identifier in a PCH that
imports the Cocoa module on Darwin, it was taking 2 to 5 seconds
because we were hammering the MapVector::erase() function, which is
O(n).  For now, just clear() the contained SmallVector to get back to
0.25 - 0.5 seconds.  This is probably not the long-term fix, because
without modules or without PCH the performance is more like 0.02
seconds.

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

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=234655&r1=234654&r2=234655&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Apr 10 17:25:42 2015
@@ -8668,7 +8668,10 @@ void ASTReader::pushExternalDeclIntoScop
     if (It != PendingFakeLookupResults.end()) {
       for (auto *ND : PendingFakeLookupResults[II])
         SemaObj->IdResolver.RemoveDecl(ND);
-      PendingFakeLookupResults.erase(It);
+      // FIXME: this works around module+PCH performance issue.
+      // Rather than erase the result from the map, which is O(n), just clear
+      // the vector of NamedDecls.
+      It->second.clear();
     }
   }
 


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to