Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-26237

QtCreator hangs for more than 10s with live clazy analysis

    XMLWordPrintable

Details

    • Windows
    •  bf275331dd28b4706127029d2941b9163461ae14

    Description

      When working with Qt Creator, editing a file cause several analysis to be done on the file ("Analyse open files" is enabled in clang tools configuration) :
       - Clang Code Model
       - Clang tidy
       - Clazy

       

      I've encountered first this issue while editing code of qjackctl project (https://github.com/rncbc/qjackctl which is a Qt/cmake project.

      This works fine, but when the analysis is done, Qt Creator launches many clazy processes for around 13s on my PC and while doing this the GUI is frozen. There are a total of 87 clazy processes spawned in my case, after editing qjackctlMainForm.cpp.

      This means the GUI is effectively frozen for 13s busy creating processes.

      Here is a part of which process QtCreator is spawning:

      Here are the stacktrace of each process spawn where are all similar:

       

      According to my reading of the code, this happens because:

      1. When clazy has done some diagnostics, Qt Creator iterate each of them in DocumentClangToolRunner::onSuccess
      2. When iterating them, it create a new DiagnosticMark (https://github.com/qt-creator/qt-creator/blob/72536eb1555db00723dfbd72c80c940ccabfb2b3/src/plugins/clangtools/documentclangtoolrunner.cpp#L303)
      3. In the constructor of DiagnosticMark, the tooltip is made by calling the createDiagnosticToolTipString function
      4. While creating the tooltip text for the diagnostic, that function will retrieve information about the diagnostic, in particular its documentation URL (https://github.com/qt-creator/qt-creator/blob/72536eb1555db00723dfbd72c80c940ccabfb2b3/src/plugins/clangtools/clangtoolsutils.cpp#L125)
      5. As this is a clazy diagnostic, it will call clazyDocUrl
      6. The first line of this function will retrieve the clazy's version (https://github.com/qt-creator/qt-creator/blob/72536eb1555db00723dfbd72c80c940ccabfb2b3/src/plugins/clangtools/clangtoolsutils.cpp#L367)
      7. Retrieving the version will create an instance of ClazyStandaloneInfo (https://github.com/qt-creator/qt-creator/blob/72536eb1555db00723dfbd72c80c940ccabfb2b3/src/plugins/clangtools/clangtoolssettings.cpp#L230)
      8. Which in turn will end up calling runExecutable 3 times:
      // In clangtoolssettings.cpp:
      [...]
      QVersionNumber ClangToolsSettings::clazyVersion()
      {
          return ClazyStandaloneInfo(ClangTools::Internal::clazyStandaloneExecutable()).version;
      }
      [...]
      
      // In executableinfo.cpp:
      [...]
      static QStringList queryClangTidyChecks(const QString &executable,
                                              const QString &checksArgument)
      {
          QStringList arguments = QStringList("-list-checks");
      [...]
          QString output = runExecutable(commandLine, QueryFailMode::Noisy);
          if (output.isEmpty())
              return {};
      
      [...]
      static ClazyChecks querySupportedClazyChecks(const QString &executablePath)
      {
          static const QString queryFlag = "-supported-checks-json";
          QString jsonOutput = runExecutable(CommandLine(executablePath, {queryFlag}),
                                             QueryFailMode::Noisy);
      [...]
      
      ClazyStandaloneInfo::ClazyStandaloneInfo(const QString &executablePath)
          : defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
          , supportedChecks(querySupportedClazyChecks(executablePath))
      {
          QString output = runExecutable(CommandLine(executablePath, {"--version"}),
                                         QueryFailMode::Silent);
      [...]
      

      Attachments

        Activity

          People

            kandeler Christian Kandeler
            amurzeau Alexis Murzeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: