Qt Creator
  1. Qt Creator
  2. QTCREATORBUG-15365

Clang Model: code completion speed regression

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: P2: Important P2: Important
    • Resolution: Done
    • Affects Version/s: Qt Creator 3.6.0-beta1, Qt Creator 4.0.0-beta1
    • Fix Version/s: Qt Creator 3.6.0
    • Component/s: C/C++/Obj-C++ Support
    • Labels:
      None
    • Environment:

      Windows 8, VS2013 x86, clang 3.6.2

      Description

      Qt Creator 3.5.1 on subsequent code completions gets faster with the second code completion.

      Qt Creator 3.7.0 (master branch) takes the same amount of time for the same code completion command e.g. "this->".

      I used Lyx project to test this regression: git clone git://git.lyx.org/lyx

      My CMake configure parameters were:

      -DLYX_DEPENDENCIES_DOWNLOAD -DLYX_USE_QT=QT5 -DCMAKE_PREFIX_PATH=c:\Qt\Qt5.5.1\5.5\msvc2013\lib\cmake\
      

      Went to the last method in Text3.cppText::inDescriptionItem and added a this->. Took like ~6 seconds to
      get the popup (older i7 2.6GHz CPU). During the ~6 seconds I didn't see any Windows wait cursor.

      On Qt Creator master on every this-> I get like ~6 seconds.

      With Qt Creator 3.5.1 the first time is slow the next times are way faster, like one second.

      I've used the same libclang.dll for both Qt Creator 3.5.1 and Qt Creator 3.7.0 (master), the latter shouldn't be ~6x slower.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Cristian Adam added a comment - - edited

        I've commented out #include <config.h> from Text3.cpp and tested with Qt Creator 3.5.1 and Qt Creator 3.6 RC1.

        Qt Creator 3.5.1

        Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup.

        [4752] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForCodeCompletion needed 0 ms
        [4752] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 5213 ms
        

        Pressed Ctrl+Space and then Esc to close completion popup.

        [4752] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForCodeCompletion needed 0 ms
        [4752] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 514 ms
        

        Hit Backspace and then > and then Escape to close completion popup

        [4752] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForCodeCompletion needed 0 ms
        [4752] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 637 ms
        

        Qt Creator 3.6 RC1

        Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup.

        [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms
        [1040] qtc.clangbackend.timers: ClangIpcServer::requestDiagnostics needed 5732 ms
        [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms
        [1040] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 4738 ms
        

        Pressed Ctrl+Space and then Esc to close completion popup.

        [1040] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 98 ms
        

        Hit Backspace and then > and then Escape to close completion popup

        [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms
        [1040] qtc.clangbackend.timers: ClangIpcServer::requestDiagnostics needed 5806 ms
        [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms
        [1040] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 4725 ms
        

        Note

        Please note that both Qt Creator 3.5.1 and Qt Creator 3.6 RC1 have created exactly two preamble*.pch files.

        Qt Creator 3.6 RC1 after rerunning CMake

        Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup.

        [2636] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms
        [2636] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 8472 ms
        

        Pressed Ctrl+Space and then Esc to close completion popup.

        [2636] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 97 ms
        

        Hit Backspace and then > and then Escape to close completion popup

        [2636] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms
        [2636] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 5355 ms
        

        After running CMake on the project the calls to ClangIpcServer::requestDiagnostics needed are gone, but the last step still takes ~8x times longer than on Qt Creator 3.5.1 and this is what people would expect all the time, editing the same file and ask for code completion.

        Step 3 needs to be faster.

        Regarding preamble pch files, the Qt Creator 3.5.1 (reran CMake also for 3.5.1, times are similar to the ones I posted above) sizes are:

        11/28/2015  10:47 AM        25,648,936 preamble-6b1ad7.pch
        11/28/2015  10:47 AM        27,356,876 preamble-a3d632.pch
        

        while the Qt Creator 3.6 RC1 sizes are:

        11/28/2015  10:39 AM        27,953,084 preamble-c8cf45.pch
        11/28/2015  10:39 AM        27,952,792 preamble-d85fcd.pch
        
        Show
        Cristian Adam added a comment - - edited I've commented out #include <config.h> from Text3.cpp and tested with Qt Creator 3.5.1 and Qt Creator 3.6 RC1. Qt Creator 3.5.1 Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup. [4752] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForCodeCompletion needed 0 ms [4752] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 5213 ms Pressed Ctrl+Space and then Esc to close completion popup. [4752] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForCodeCompletion needed 0 ms [4752] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 514 ms Hit Backspace and then > and then Escape to close completion popup [4752] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForCodeCompletion needed 0 ms [4752] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 637 ms Qt Creator 3.6 RC1 Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup. [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms [1040] qtc.clangbackend.timers: ClangIpcServer::requestDiagnostics needed 5732 ms [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms [1040] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 4738 ms Pressed Ctrl+Space and then Esc to close completion popup. [1040] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 98 ms Hit Backspace and then > and then Escape to close completion popup [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms [1040] qtc.clangbackend.timers: ClangIpcServer::requestDiagnostics needed 5806 ms [1040] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms [1040] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 4725 ms Note Please note that both Qt Creator 3.5.1 and Qt Creator 3.6 RC1 have created exactly two preamble*.pch files. Qt Creator 3.6 RC1 after rerunning CMake Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup. [2636] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms [2636] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 8472 ms Pressed Ctrl+Space and then Esc to close completion popup. [2636] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 97 ms Hit Backspace and then > and then Escape to close completion popup [2636] qtc.clangbackend.timers: ClangIpcServer::updateTranslationUnitsForEditor needed 0 ms [2636] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 5355 ms After running CMake on the project the calls to ClangIpcServer::requestDiagnostics needed are gone, but the last step still takes ~8x times longer than on Qt Creator 3.5.1 and this is what people would expect all the time, editing the same file and ask for code completion. Step 3 needs to be faster. Regarding preamble pch files, the Qt Creator 3.5.1 (reran CMake also for 3.5.1, times are similar to the ones I posted above) sizes are: 11/28/2015 10:47 AM 25,648,936 preamble-6b1ad7.pch 11/28/2015 10:47 AM 27,356,876 preamble-a3d632.pch while the Qt Creator 3.6 RC1 sizes are: 11/28/2015 10:39 AM 27,953,084 preamble-c8cf45.pch 11/28/2015 10:39 AM 27,952,792 preamble-d85fcd.pch
        Hide
        Marco Bubke added a comment -

        My timings are:
        parsing ~3s
        reparsing ~500ms
        code completion ~40

        My machine a only a slow dual core but it has a SSD so this can make the difference. What is your atime setting? My is noatime.

        The reparsing depends on the include and file size.

        Show
        Marco Bubke added a comment - My timings are: parsing ~3s reparsing ~500ms code completion ~40 My machine a only a slow dual core but it has a SSD so this can make the difference. What is your atime setting? My is noatime. The reparsing depends on the include and file size.
        Hide
        Cristian Adam added a comment -

        I've done my tests on Windows. It's being mentioned in the Environment field of the bug report.

        I will post the results from Linux (Kubuntu 15.10 x64), just to see how Lyx behaves on Linux.

        Show
        Cristian Adam added a comment - I've done my tests on Windows. It's being mentioned in the Environment field of the bug report. I will post the results from Linux (Kubuntu 15.10 x64), just to see how Lyx behaves on Linux.
        Hide
        Marco Bubke added a comment -

        Found it:

        We used CXTranslationUnit_SkipFunctionBodies but removed it because we provide diagnostics and highlighting by the some translation unit.
        As a workaround we can disable reparsing before a code completion.

        Show
        Marco Bubke added a comment - Found it: We used CXTranslationUnit_SkipFunctionBodies but removed it because we provide diagnostics and highlighting by the some translation unit. As a workaround we can disable reparsing before a code completion.
        Hide
        Cristian Adam added a comment -

        Qt Creator 3.6.0

        I've installed Qt Creator 3.6.0 and give it another try.

        Opened Text3.cpp and waited for this line in the DebugView

        [35436] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForEditor needed 11316 ms
        

        It took some time because I used Visual C++ 2013 and Text3.cpp has a lot of dependencies.
        After going to the "Inspect C++ Code Model" and in the %temp% directory, I could see qtc-codemodelinspection_b52c2f91f5_151216_232524.txt
        which was 13MB in size!

        Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup.

        [35436] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 105 ms
        

        Pressed Ctrl+Space and then Esc to close completion popup.

        [35436] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 118 ms
        

        Hit Backspace and then > and then Escape to close completion popup

        [35436] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 102 ms
        

        The bug is fixed! Thank you.

        Show
        Cristian Adam added a comment - Qt Creator 3.6.0 I've installed Qt Creator 3.6.0 and give it another try. Opened Text3.cpp and waited for this line in the DebugView [35436] qtc.clangbackend.timers: ClangIpcServer::registerTranslationUnitsForEditor needed 11316 ms It took some time because I used Visual C++ 2013 and Text3.cpp has a lot of dependencies. After going to the "Inspect C++ Code Model" and in the %temp% directory, I could see qtc-codemodelinspection_b52c2f91f5_151216_232524.txt which was 13MB in size! Added \nthis-> in the last method from Text3.cpp and pressed Esc to close completion popup. [35436] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 105 ms Pressed Ctrl+Space and then Esc to close completion popup. [35436] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 118 ms Hit Backspace and then > and then Escape to close completion popup [35436] qtc.clangbackend.timers: ClangIpcServer::completeCode needed 102 ms The bug is fixed! Thank you.

          People

          • Assignee:
            Marco Bubke
            Reporter:
            Cristian Adam
          • Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes