> On Nov 18, 2015, at 9:36 AM, Manuel Klimek <kli...@google.com> wrote:
> 
> 
> 
> On Wed, Nov 18, 2015 at 6:19 PM Douglas Gregor <dgre...@apple.com 
> <mailto:dgre...@apple.com>> wrote:
> 
> 
> Sent from my iPhone
> 
> On Nov 18, 2015, at 8:19 AM, Manuel Klimek <kli...@google.com 
> <mailto:kli...@google.com>> wrote:
> 
>> (now with the right list)
>> 
>> On Tue, Nov 16, 2010 at 12:03 AM Douglas Gregor <dgre...@apple.com 
>> <mailto:dgre...@apple.com>> wrote:
>> Author: dgregor
>> Date: Mon Nov 15 17:00:34 2010
>> New Revision: 119285
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=119285&view=rev 
>> <http://llvm.org/viewvc/llvm-project?rev=119285&view=rev>
>> Log:
>> Tweak libclang's heuristics for building precompiled preambles and
>> caching global code-completion results. In particular, don't perform
>> either operation the first time we parse, but do both after the first
>> reparse.
>> 
>> Do you remember the reason behind not building the preamble on the first 
>> parse? For really large TUs having to parse 2 times before we get a preamble 
>> is rather painful.
> 
> We wanted to get the first set of results quickly, especially for syntax 
> coloring when a file is first opened. 
> 
> Do you remember how much storing the preamble would make this slower (without 
> the preamble many of our parses are >> 20 seconds, so 2x that is rather 
> unfortunate). Perhaps we can add a flag?

I don’t remember the numbers from… 5 years ago. I do remember that it was a 
noticeable lag in the UI when opening a new file, primarily because the AST 
serialization step needed to produce the preamble file is fairly expensive. You 
can turn on the timers by setting the LIBCLANG_TIMING environment variable to 
see how long things are taking without having to recompile, since it’s probably 
worth re-measuring now.

        - Doug

>  
> 
>> 
>> Cheers,
>> /Manuel 
>> 
>> 
>> Modified:
>>     cfe/trunk/lib/Frontend/ASTUnit.cpp
>>     cfe/trunk/tools/c-index-test/c-index-test.c
>> 
>> Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=119285&r1=119284&r2=119285&view=diff
>>  
>> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=119285&r1=119284&r2=119285&view=diff>
>> ==============================================================================
>> --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
>> +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Nov 15 17:00:34 2010
>> @@ -326,7 +326,6 @@
>> 
>>    // Make a note of the state when we performed this caching.
>>    NumTopLevelDeclsAtLastCompletionCache = top_level_size();
>> -  CacheCodeCompletionCoolDown = 15;
>>  }
>> 
>>  void ASTUnit::ClearCachedCompletionResults() {
>> @@ -824,12 +823,6 @@
>>    }
>> 
>>    Invocation.reset(Clang.takeInvocation());
>> -
>> -  // If we were asked to cache code-completion results and don't have any
>> -  // results yet, do so now.
>> -  if (ShouldCacheCodeCompletionResults && CachedCompletionResults.empty())
>> -    CacheCodeCompletionResults();
>> -
>>    return false;
>> 
>>  error:
>> @@ -1350,7 +1343,7 @@
>> 
>>    llvm::MemoryBuffer *OverrideMainBuffer = 0;
>>    if (PrecompilePreamble) {
>> -    PreambleRebuildCounter = 1;
>> +    PreambleRebuildCounter = 2;
>>      OverrideMainBuffer
>>        = getMainBufferWithPrecompiledPreamble(*Invocation);
>>    }
>> @@ -1377,6 +1370,7 @@
>>    AST->CaptureDiagnostics = CaptureDiagnostics;
>>    AST->CompleteTranslationUnit = CompleteTranslationUnit;
>>    AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
>> +  AST->CacheCodeCompletionCoolDown = 1;
>>    AST->Invocation.reset(CI);
>> 
>>    return AST->LoadFromCompilerInvocation(PrecompilePreamble)? 0 : 
>> AST.take();
>> @@ -1481,6 +1475,7 @@
>>    AST->CaptureDiagnostics = CaptureDiagnostics;
>>    AST->CompleteTranslationUnit = CompleteTranslationUnit;
>>    AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
>> +  AST->CacheCodeCompletionCoolDown = 1;
>>    AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
>>    AST->NumStoredDiagnosticsInPreamble = StoredDiagnostics.size();
>>    AST->StoredDiagnostics.swap(StoredDiagnostics);
>> 
>> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=119285&r1=119284&r2=119285&view=diff
>>  
>> <http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=119285&r1=119284&r2=119285&view=diff>
>> ==============================================================================
>> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
>> +++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Nov 15 17:00:34 2010
>> @@ -1040,6 +1040,11 @@
>>      fprintf(stderr, "Unable to load translation unit!\n");
>>      return 1;
>>    }
>> +
>> +  if (clang_reparseTranslationUnit(TU, 0, 0, 
>> clang_defaultReparseOptions(TU))) {
>> +    fprintf(stderr, "Unable to reparse translation init!\n");
>> +    return 1;
>> +  }
>> 
>>    for (I = 0; I != Repeats; ++I) {
>>      results = clang_codeCompleteAt(TU, filename, line, column,
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-comm...@cs.uiuc.edu <mailto:cfe-comm...@cs.uiuc.edu>
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits 
>> <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits>

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to