GoingNative 35: Fast Tips for Faster Builds!

Sign in to queue

Description

(Sorry for the delay! Look forward to 2 episodes in March!)

Today's episode is packed with practical tips to significantly speed up your build time (we ain't talking chump change) that you can apply immediately after watching! Join our build throughput expert (as well as our intern!) as we guide you through the steps to decrease your downtime and pump your productivity!

Video Timeline
[1:24] Meet Sridhar
[2:04] VS2013 build times: RTM vs. Update 3
[3:54] How we achieved those gains
    [4:16] Improved incremental linking
    [4:45] Improved PDB generation
    [5:03] New switch: /Zc:inline
        For more info, see our blog post.
[6:16] VS2015 Build Throughput Principles: Improving Incremental Builds
[7:37] Free gains with template processing in VS2015
[9:27] Squeezing out more gains
    [9:50] /debug:fastlink
    [11:00] /ltcg:incremental
[13:03] Precompiled Header (PCH) Tool (Intern Project!)
    [14:17] Meet Nikolai
    [14:58] What is a PCH?
    [15:25] Why should I use it?
    [15:42] What should I put into it?
    [16:42] PCH Tool Demo
        Download the tool here!
[20:02] Example build throughput gains in VS2015
[21:23] Reporting your build issues to us
    [22:18] Build timing
    [23:33] /bt+ and /time+
        Send your logs to aasthan at microsoft dot com
[26:38] Final recommendations: build systems
    Check out IncrediBuild at https://www.incredibuild.com/

Don't have the latest update to VS2013 yet? Click here! (Or tell us in the comments why you haven't)

And be sure to try out the latest VS2015 build here! (And also tell us in the comments why not =P)

Embed

Download

Download this episode

The Discussion

  • User profile image
    freefly

    May be you guys, put a caption on every C++ videos "Sorry for the Delay - Videos".
    Unfortunately, these are the only C++ stuff coming out and that too when you guys get to remember about it. You apologize for once or twice, not for every other post that comes out.

  • User profile image
    scarroll

    freefly, a fair point.   We'll endeavor to get these up on time.   Thanks for watching!

  • User profile image
    philippecp

    Very informative video! I do have some additional questions however.

    1. What is the compilation overhead of including an unused header like say <map>? Is there any way to get a warning when a header is included but never used so that I can go and remove it?
    2. What is the compilation overhead of including a header with class declaration vs simply a forward declaration? What about for inline template classes like stl? Is there any way for the compiler or the analysis tool to let me know when I'm including a class declaration when a forward declaration is all that is needed (like <iosfwd>)?

    Thanks!

  • User profile image
    dakotahawki​ns

    One speedup (not large, but something) we implemented pretty simply involves manipulating %TEMP%.

    On our standard machine configuration, there are two partitions (C: and D:). C: contains what it normally would (including user profiles and default %TEMP%), while D: usually contains all of our code.

    A while ago I guessed that since the build process utilizes %TEMP% pretty heavily, some of that might include moving files between %TEMP% and your build output locations. If everything is on the same partition, file moves are instantaneous, but if they're on separate partitions you're going to pay the price of a copy/delete.

    What we tried was to "wrap" our build process with a batch file that changes %TEMP% while the build runs so that it sees %TEMP% on the same partition as the code and build output:

    TempVars.bat:

    @ECHO OFF
    setlocal ENABLEDELAYEDEXPANSION
    
    IF /I "%1" == "create" (
        IF NOT DEFINED BUILD_TEMP (
            FOR %%f IN ("%CD%") DO SET BUILD_TEMP=%%~sf\BUILD_TEMP
        )
        IF DEFINED TMP (
            IF /I "%CD:~0,1%" NEQ "%TMP:~0,1%" (
                SET TMP=!BUILD_TEMP!
            )
        )
        IF DEFINED TEMP (
            IF /I "%CD:~0,1%" NEQ "%TEMP:~0,1%" (
                SET TEMP=!BUILD_TEMP!
            )
        )
        ECHO Create !BUILD_TEMP!
        IF NOT EXIST "!BUILD_TEMP!" MKDIR "!BUILD_TEMP!"
        GOTO Done
    )
    
    IF /I "%1" == "remove" (
        ECHO Remove !BUILD_TEMP!
        IF /I "!BUILD_TEMP!" NEQ "" (
            RMDIR /S /Q !BUILD_TEMP!
        )
    
        GOTO Done
    )
    
    :Done

    So we just run that from the source directory with "create", do our build, then run it again with "remove".

    We got a minor speedup so we didn't do any in-depth analysis to confirm our suspicion, but I would like to hear more from you guys.

    Your mileage may very, but it's pretty easy to do and every little bit helps :)

  • User profile image
    Sridhar Madhugiri

    @philippecp

    Including unused headers has an impact on the build time / working set of the compiler. The cost of unused header varies based on their content. Size of the header, number of symbols and types in the file all impact build time. In general, Template heavy code with inline definition of methods imposes a higher penalty than “C” style headers with function declarations and struct definitions.

    Warning about “just need a forward declare” is an interesting idea. We have a number of other ideas on our backlog to identify patterns that impact build times. Ideally we want to surface as many of the issues as possible at design time and have a switch in the compiler that identifies issues that cannot be detected at design time.

    Thanks for the feedback!

  • User profile image
    Dustin Land

    The OS file cache can have a significant impact on subsequent run times for a test like the PCH one you conducted. I'd be curious to see the compile time after a cold boot.

  • User profile image
    jalf

    I enabled Project Timings on our solution (containing around 200 projects), and I can see that a significant amount of time (around 750 seconds) is being spent on ResolveProjectReferences.

    What does that phase cover, exactly? Is that 750 seconds of actual work, or is it time spent waiting for a dependency to complete building, or something like that?

    Is there anything I can do to speed up this specific task?

  • User profile image
    XTF

    I love all the warnings flying by in the PCH demo. :P

  • User profile image
    ariccio
  • User profile image
    piyawan

    Thank! you!
    I feel my Visual Studio run faster now after I re-config something. (Disable Auto update)

  • User profile image
    Yossi Zinger

    Suppose I have a C++ file that takes a long time (over 5 minutes) to compile. I understand Microsoft wants to get information about this. Who should I contact?

  • User profile image
    gha11

    @Yossi Zinger: Contact sridmad and aasthan, both at microsoft dot com.

    @jalf: I'd encourage you to do the same; sorry for the delay!

  • User profile image
    Rohit Jainendra

    Hi all, encourage you to also check out Huddle and ElectricAccelerator from Electric Could to speed up your builds and tests with guaranteed accurate results.

Add Your 2 Cents