Uploaded image for project: 'Qt Visual Studio Tools'
  1. Qt Visual Studio Tools
  2. QTVSADDINBUG-1030

Slow compilation time because of a lot of MSBuild GetReferencesVCProjectInfo

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 2.9.1 (rev.06)
    • Fix Version/s: None
    • Component/s: Build-time integration
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      I'm experiencing really slow compilation time in my solution. More exactly for each and every compilations (whole solution, or single file) it takes several seconds (usually ~10 seconds) before it starts to compile a file).

      I've used Cpp Build Insights (Introducing C++ Build Insights - C++ Team Blog (microsoft.com)) to track what's going on.

      I've noticed that the before it starts to compile any file, it spends a lot of time in MSBuild tasks to gather information about referenced projects (GetReferencedVCProjectInfo). And it happens only with Qt projects.

      Sample code

      To go further, I've created 2 use cases solution very similar:

      • A console application with a main.cpp
      • A bunch of libraries projects containing "a lot" of dummy files (.h / .cpp)
      • The console application references all libraries, library 1 references libraries from 2 to 7, library 2 references libraries from 3 to 7, etc... to create a dependency graph
      • All projects include some property sheets (.props)

      All projects are created with the default VS templates. The 2 use cases are:

      • Regular VisualC++ projects without Qt
      • Qt projects

      You can find these solutions attached to this ticket (Perf_WithQt, PerfWithoutQt).

      Measurements

      The goal was to measure the compilation of the console application main.cpp file only (not the whole solution).

       

        Without Qt With Qt
      main.cpp (single file) 1.5 sec 8 sec

       

      Of course, the content of the 2 main files are not the same, but the problem doesn't come from the content of these files, it comes from the build system.

      Now I focus on the Qt solution only. I've tested step by step like if I was building the solution from scratch:

      1. I create the QtConsoleApplication only, without any referenced project, without property sheet
      2. I add the library projects, with the referenced projects, without property sheet, without source files (empty project)
      3. I add the source files contained in the 'NewFolder1' sub folder for each libraries
      4. I add the property sheet Project.props on the console application project only
      5. I add the property sheet Project.props on all libraries projects
        With Qt
      1. Console application only  0.8 sec
      2. Add library reference projects 1.4 sec
      3. Add files in libraries 5 sec
      4. Add property sheet to console application only 6.5 sec
      5. Add property sheet to all libraries 8 sec

      So basically, to compile a single file, it's 10 times slower in this example.

      This issue seems to be once per project. So for example if I notice a 10 seconds overhead to compile a single file for a particular project, I notice the same 10 seconds overhead to compile the whole project. The more a project has references, the bigger the overhead is. At work, we have about 100 projects, this become a real issue when the total overhead is 100 x [5~15 seconds].

      Somehow, this overhead is more or less equal to:

      overhead = [number of referenced projects] x [number of files in referenced project] x [complexity of the project settings (aka. property sheets)].

      And as we saw in the table above, the biggest factor seems to be the number of files in the referenced projects.

        Attachments

        1. image-2022-08-18-12-20-05-095.png
          image-2022-08-18-12-20-05-095.png
          13 kB
        2. image-2022-08-18-12-20-10-170.png
          image-2022-08-18-12-20-10-170.png
          185 kB
        3. Perf_WithoutQt.7z
          14 kB
        4. Perf_WithQt.7z
          33 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            mecfc Miguel Costa
            Reporter:
            tony.riviere Tony Riviere
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes