Giter Club home page Giter Club logo

cpp-build-insights-samples's Introduction

page_type languages products description urlFragment
sample
C++
cpp-build-insights
This repository provides buildable and runnable samples for the C++ Build Insights SDK. Use it as a learning resource.
cpp-build-insights-samples

C++ Build Insights SDK samples

License

This repository provides buildable and runnable samples for the C++ Build Insights SDK. Use it as a learning resource.

Contents

Sample Description
BottleneckCompileFinder Finds CL invocations that are bottlenecks and don't use /MP.
FunctionBottlenecks Prints a list of functions that are code generation bottlenecks within their CL or Link invocation.
LongCodeGenFinder Lists the functions that take more than 500 milliseconds to generate in your entire build.
RecursiveTemplateInspector Identifies costly recursive template instantiations.
TopHeaders Determines which headers you might want to precompile.
LongModuleFinder Identifies costly module interface IFC creation. Requires trace with code built using MSVC version 16.10 or later and using SDK version Microsoft.Cpp.BuildInsights 1.2.0 or later.
LongHeaderUnitFinder Identifies costly header unit IFC creation. Requires trace with code built using MSVC version 16.10 or later and using SDK version Microsoft.Cpp.BuildInsights 1.2.0 or later.
LongPrecompiledHeaderFinder Identifies costly precompiled header (PCH) IFC creation. Requires trace with code built using MSVC version 16.10 or later and using SDK version Microsoft.Cpp.BuildInsights 1.2.0 or later.

Prerequisites

In order to build and run the samples in this repository, you need:

  • Visual Studio 2017 and above.
  • Windows 8 and above.

Build steps

  1. Clone the repository on your machine.
  2. Open the Visual Studio solution file. Each sample is a separate project within the solution.
  3. All samples rely on the C++ Build Insights SDK NuGet package. Restore NuGet packages and accept the license for the SDK.
  4. Build the desired configuration for the samples that interest you. Available platforms are x86 and x64, and available configurations are Debug and Release.
  5. Samples will be built in their own directory following this formula: {RepositoryRoot}\out\{SampleName}.

Running the samples

  1. The samples require CppBuildInsights.dll and KernelTraceControl.dll to run. These files are available in the C++ Build Insights NuGet package. When building samples, these files are automatically copied next to them in their respective output directory. If you are going to move a sample around on your machine, please be sure to move these DLL's along with it.
  2. Collect a trace of the build you want to analyze with the sample. You can do this using two methods:
    1. Use vcperf:
      1. Open an elevated x64 Native Tools Command Prompt for VS 2019.
      2. Run the following command: vcperf /start MySessionName
      3. Build your project. You do not need to use the same command prompt for building.
      4. Run the following command: vcperf /stopnoanalyze MySessionName outputTraceFile.etl
    2. Programmatically: see the C++ Build Insights SDK documentation for details.
  3. Invoke the sample, passing your trace as the first parameter.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

cpp-build-insights-samples's People

Contributors

helena-gregg avatar kevcadieux avatar microsoft-github-operations[bot] avatar microsoftopensource avatar mwallner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpp-build-insights-samples's Issues

Formatting Bug? LongModuleFinder

Hi! I was working on some of the samples and realized that there was a strange formatting error on LongModuleFinder

LongModuleFinder output:

LongModuleFinderScreenshot

The formatting issue can be seen on the right where the 2 from CL Invocation has no space between itself and Duration

Looking at the code, I see no reason why it should be formatting strangely since there are two tab escapes:

std::cout << "\t\tCL Invocation " << frontEndPassData.InvocationId << "\t\tDuration: " << frontEndPassData.Duration << " s " << std::endl;



Note: similar code can be found in the other analyzers as seen below (outputs in terminal as expected)

for (auto& frontEndPassData : sortedFrontEndPassData)
{
std::cout << "File Name: ";
std::wcout << frontEndPassData.Name;
std::cout << "\t\tCL Invocation " << frontEndPassData.InvocationId << "\t\tDuration: " << frontEndPassData.Duration << " s " << std::endl;
}

for (auto& frontEndPassData : sortedFrontEndPassData)
{
std::cout << "File Name: ";
std::wcout << frontEndPassData.Name;
std::cout << "\t\tCL Invocation " << frontEndPassData.InvocationId << "\t\tDuration: " << frontEndPassData.Duration << " s " << std::endl;
}

how to use the samples

hi,

i would like to try the samples. but im lost with documentation

image

the etl contins all needed file stuff etc! are the exes supose to do something?

Exception when running any samples

Exception thrown at 0x00007FFB309F3A22 (CppBuildInsights.dll) in TopHeaders.exe: 0xC0000005: Access violation reading location 0x0000000000000000. occurred

It appears to be triggered after all calls to OnStopFile (I think). I'm going to try to hack around it with some SEH in the meantime.

Call stacks are not consistent when getting this error - maybe uninitialized memory? Example from TopHeaders release build
CppBuildInsights.dll!00007ffb48163a22() Unknown
CppBuildInsights.dll!00007ffb48164874() Unknown
CppBuildInsights.dll!00007ffb48178119() Unknown
CppBuildInsights.dll!00007ffb4817c7d2() Unknown
CppBuildInsights.dll!00007ffb4817a0ed() Unknown

[Inline Frame] TopHeaders.exe!Microsoft::Cpp::BuildInsights::Analyze(const char *) Line 3376 C++
TopHeaders.exe!main(int argc, char * * argv) Line 171 C++

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.