Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profiler under a flag #2765

Merged
merged 8 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build/NuGetPackages/Microsoft.Build.Framework.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
<dependencies>
<group targetFramework=".NETStandard1.3">
<dependency id="System.Threading.Tasks.Parallel" version="4.0.1" />
<dependency id="System.Resources.ResourceManager" version="4.0.1" />
<dependency id="System.Runtime.Extensions" version="4.1.0" />
<dependency id="System.Collections" version="4.0.11" />
<dependency id="System.Diagnostics.Debug" version="4.0.11" />
<dependency id="System.Globalization" version="4.0.11" />
<dependency id="System.Linq" version="4.1.0" />
<dependency id="System.Resources.ResourceManager" version="4.0.1" />
<dependency id="System.ObjectModel" version="4.0.12" />
<dependency id="System.Runtime" version="4.1.0" />
<dependency id="System.Runtime.InteropServices" version="4.1.0" />
<dependency id="System.Threading" version="4.0.11" />
Expand Down
40 changes: 40 additions & 0 deletions documentation/evaluation-profiling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# MSBuild evaluation profiling

This branch contains an evaluation profiler, which can help analyze which parts of a project (and any .targets/etc that it imports) are taking the most time to evaluate.

The profiler is enabled when passing /profileevaluation:<filename> as a command-line argument to MSBuild. The provided filename is used for generating a profiler report that looks like the following:

Pass|File|Line #|Expression|Inc (ms)|Inc (%)|Exc (ms)|Exc (%)|#|Bug
---|---|---:|---|---:|---:|---:|---:|---:|---
Total Evaluation||||650|100%|17|2.7%|1|
Initial Properties (Pass 0)||||5|0.8%|5|0.8%|1|
Properties (Pass 1)||||360|55.4%|3|0.4%|1|
ItemDefinitionGroup (Pass 2)||||9|1.4%|0|0%|1|
Items (Pass 3)||||63|9.7%|1|0.2%|1|
Lazy Items (Pass 3.1)||||173|26.6%|29|4.5%|1|
UsingTasks (Pass 4)||||8|1.2%|8|1.2%|1|
Targets (Pass 5)||||15|2.3%|1|0.2%|1|
Properties (Pass 1)|MVC.csproj|0|`<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.Web" />`|351|54%|76|11.7%|1|
Items (Pass 3)|Microsoft.NETCore.App.props|8|`<PackageConflictPlatformManifests Include="$(MSBuildThisFileDirectory)Microsoft.NETCore.App.Platform...`|37|5.7%|37|5.7%|1|
Properties (Pass 1)|Microsoft.Common.CurrentVersion.targets|83|`<FrameworkPathOverride Condition="'$(FrameworkPathOverride)' == ''" >$([Microsoft.Build.Utilities.To...`|32|4.9%|32|4.9%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.DefaultItems.props|26|`<Compile Include="**/*$(DefaultLanguageSourceExtension)" Exclude="$(DefaultItemExcludes);$(DefaultEx...`|31|4.7%|31|4.7%|1|
Properties (Pass 1)|Microsoft.Common.targets|114|`<Import Project="$(CommonTargetsPath)" />`|95|14.6%|23|3.5%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.Web.ProjectSystem.props|29|`<Content Include="wwwroot\**" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes...`|17|2.6%|17|2.6%|1|
Properties (Pass 1)|Microsoft.Common.CurrentVersion.targets|92|`<TargetPlatformSdkPath Condition="'$(TargetPlatformSdkPath)' == ''" >$([Microsoft.Build.Utilities.To...`|15|2.3%|15|2.3%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.DefaultItems.targets|156|`Condition="'%(LinkBase)' != ''")`|12|1.9%|12|1.9%|1|
Properties (Pass 1)|Microsoft.Common.props|15|`Condition="'$(ImportByWildcardBeforeMicrosoftCommonProps)' == ''")`|12|1.9%|12|1.9%|1|
Properties (Pass 1)|Microsoft.Common.props|63|`<Import Project="$(MSBuildProjectExtensionsPath)$(MSBuildProjectFile).*.props" Condition="'$(ImportP...`|18|2.8%|12|1.8%|1|
Properties (Pass 1)|Microsoft.CSharp.targets|168|`<Import Project="$(CSharpTargetsPath)" />`|164|25.2%|11|1.7%|1|
Properties (Pass 1)|MVC.csproj.nuget.g.targets|7|`<Import Project="$(NuGetPackageRoot)netstandard.library\2.0.0\build\netstandard2.0\NETStandard.Libra...`|14|2.2%|11|1.7%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.DefaultItems.props|30|`<None Include="**/*" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />`|10|1.6%|10|1.6%|1|
Properties (Pass 1)|Sdk.props|29|`<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />`|56|8.6%|10|1.5%|1|
Items (Pass 3)|Microsoft.Common.CurrentVersion.targets|368|`Condition="'$(OutputType)' != 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == ''")`|9|1.4%|9|1.4%|1|
ItemDefinitionGroup (Pass 2)|Microsoft.Common.CurrentVersion.targets|1661|`<ProjectReference ><!-- Target to build in the project reference; by default, this property is blank...`|8|1.3%|8|1.3%|1|
Lazy Items (Pass 3.1)|Microsoft.Common.CurrentVersion.targets|369|`<_DebugSymbolsOutputPath Include="@(_DebugSymbolsIntermediatePath-&gt;'$(OutDir)%(Filename)%(Extensi...`|8|1.2%|8|1.2%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.Web.ProjectSystem.props|32|`<Content Include="**\*.json" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes)...`|8|1.2%|8|1.2%|1|
Properties (Pass 1)|MVC.csproj.nuget.g.targets|9|`<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration....`|8|1.2%|7|1.1%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.Web.ProjectSystem.props|39|`<Compile Remove="wwwroot\**" />`|7|1.1%|7|1.1%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.Web.ProjectSystem.props|31|`<Content Include="**\*.cshtml" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExclude...`|7|1.1%|7|1.1%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.Web.ProjectSystem.props|30|`<Content Include="**\*.config" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExclude...`|7|1.1%|7|1.1%|1|
Lazy Items (Pass 3.1)|Microsoft.NET.Sdk.DefaultItems.props|27|`<EmbeddedResource Include="**/*.resx" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFold...`|7|1.1%|7|1.1%|1|
Properties (Pass 1)|Sdk.targets|41|`<Import Project="$(LanguageTargets)" />`|171|26.2%|7|1%|1|
62 changes: 62 additions & 0 deletions ref/net46/Microsoft.Build.Framework/Microsoft.Build.Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ public partial interface INodeLogger : Microsoft.Build.Framework.ILogger
{
void Initialize(Microsoft.Build.Framework.IEventSource eventSource, int nodeCount);
}
public partial interface IProjectElement
{
string ElementName { get; }
string OuterElement { get; }
}
public partial interface ITask
{
Microsoft.Build.Framework.IBuildEngine BuildEngine { get; set; }
Expand Down Expand Up @@ -339,6 +344,7 @@ public sealed partial class ProjectEvaluationFinishedEventArgs : Microsoft.Build
{
public ProjectEvaluationFinishedEventArgs() { }
public ProjectEvaluationFinishedEventArgs(string message, params object[] messageArgs) { }
public System.Nullable<Microsoft.Build.Framework.Profiler.ProfilerResult> ProfilerResult { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string ProjectFile { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public partial class ProjectEvaluationStartedEventArgs : Microsoft.Build.Framework.BuildStatusEventArgs
Expand Down Expand Up @@ -521,6 +527,62 @@ public TelemetryEventArgs() { }
}
public delegate void TelemetryEventHandler(object sender, Microsoft.Build.Framework.TelemetryEventArgs e);
}
namespace Microsoft.Build.Framework.Profiler
{
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct EvaluationLocation
{
public EvaluationLocation(Microsoft.Build.Framework.Profiler.EvaluationPass evaluationPass, string evaluationDescription, string file, System.Nullable<int> line, Microsoft.Build.Framework.IProjectElement element) { throw null;}
public EvaluationLocation(Microsoft.Build.Framework.Profiler.EvaluationPass evaluationPass, string evaluationDescription, string file, System.Nullable<int> line, string condition) { throw null;}
public EvaluationLocation(Microsoft.Build.Framework.Profiler.EvaluationPass evaluationPass, string evaluationDescription, string file, System.Nullable<int> line, string elementName, string elementOrCondition, bool isElement) { throw null;}
public string ElementName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string ElementOrCondition { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public static Microsoft.Build.Framework.Profiler.EvaluationLocation EmptyLocation { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string EvaluationDescription { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Build.Framework.Profiler.EvaluationPass EvaluationPass { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string File { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public bool IsCondition { get { throw null; } }
public bool IsElement { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Nullable<int> Line { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
public Microsoft.Build.Framework.Profiler.EvaluationLocation WithEvaluationPass(Microsoft.Build.Framework.Profiler.EvaluationPass evaluationPass, string passDescription=null) { throw null; }
public Microsoft.Build.Framework.Profiler.EvaluationLocation WithFile(string file) { throw null; }
public Microsoft.Build.Framework.Profiler.EvaluationLocation WithFileLineAndCondition(string file, System.Nullable<int> line, string condition) { throw null; }
public Microsoft.Build.Framework.Profiler.EvaluationLocation WithFileLineAndElement(string file, System.Nullable<int> line, Microsoft.Build.Framework.IProjectElement element) { throw null; }
}
public enum EvaluationPass : byte
{
InitialProperties = (byte)1,
ItemDefintionGroups = (byte)3,
Items = (byte)4,
LazyItems = (byte)5,
Properties = (byte)2,
Targets = (byte)7,
TotalEvaluation = (byte)0,
UsingTasks = (byte)6,
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct ProfiledLocation
{
public ProfiledLocation(System.TimeSpan inclusiveTime, System.TimeSpan exclusiveTime, int numberOfHits) { throw null;}
public System.TimeSpan ExclusiveTime { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan InclusiveTime { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public int NumberOfHits { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct ProfilerResult
{
public ProfilerResult(System.Collections.Generic.IDictionary<Microsoft.Build.Framework.Profiler.EvaluationLocation, Microsoft.Build.Framework.Profiler.ProfiledLocation> profiledLocations) { throw null;}
public System.Collections.Generic.IReadOnlyDictionary<Microsoft.Build.Framework.Profiler.EvaluationLocation, Microsoft.Build.Framework.Profiler.ProfiledLocation> ProfiledLocations { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public override bool Equals(object obj) { throw null; }
public override int GetHashCode() { throw null; }
}
}
namespace Microsoft.Build.Framework.XamlTypes
{
public sealed partial class Argument : System.ComponentModel.ISupportInitialize
Expand Down
20 changes: 19 additions & 1 deletion ref/net46/Microsoft.Build/Microsoft.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ internal ProjectConfigurationInSolution() { }
public bool IncludeInBuild { get { throw null; } }
public string PlatformName { get { throw null; } }
}
public abstract partial class ProjectElement
public abstract partial class ProjectElement : Microsoft.Build.Framework.IProjectElement
{
internal ProjectElement() { }
public System.Collections.Generic.IEnumerable<Microsoft.Build.Construction.ProjectElementContainer> AllParents { get { throw null; } }
public virtual string Condition { [System.Diagnostics.DebuggerStepThroughAttribute]get { throw null; } [System.Diagnostics.DebuggerStepThroughAttribute]set { } }
public virtual Microsoft.Build.Construction.ElementLocation ConditionLocation { get { throw null; } }
public Microsoft.Build.Construction.ProjectRootElement ContainingProject { get { throw null; } }
public string ElementName { get { throw null; } }
public string Label { [System.Diagnostics.DebuggerStepThroughAttribute]get { throw null; } [System.Diagnostics.DebuggerStepThroughAttribute]set { } }
public Microsoft.Build.Construction.ElementLocation LabelLocation { get { throw null; } }
public Microsoft.Build.Construction.ElementLocation Location { get { throw null; } }
public Microsoft.Build.Construction.ProjectElement NextSibling { [System.Diagnostics.DebuggerStepThroughAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string OuterElement { get { throw null; } }
public Microsoft.Build.Construction.ProjectElementContainer Parent { [System.Diagnostics.DebuggerStepThroughAttribute]get { throw null; } }
public Microsoft.Build.Construction.ProjectElement PreviousSibling { [System.Diagnostics.DebuggerStepThroughAttribute, System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Build.Construction.ProjectElement Clone() { throw null; }
Expand Down Expand Up @@ -534,6 +536,11 @@ public enum Operation
Remove = 3,
Update = 2,
}
public sealed partial class ProfilerResultPrettyPrinter
{
public ProfilerResultPrettyPrinter() { }
public static string GetMarkdownContent(Microsoft.Build.Framework.Profiler.ProfilerResult result) { throw null; }
}
[System.Diagnostics.DebuggerDisplayAttribute("{FullPath} EffectiveToolsVersion={ToolsVersion} #GlobalProperties={_data._globalProperties.Count} #Properties={_data.Properties.Count} #ItemTypes={_data.ItemTypes.Count} #ItemDefinitions={_data.ItemDefinitions.Count} #Items={_data.Items.Count} #Targets={_data.Targets.Count}")]
public partial class Project
{
Expand Down Expand Up @@ -764,6 +771,7 @@ public enum ProjectLoadSettings
IgnoreEmptyImports = 16,
IgnoreInvalidImports = 64,
IgnoreMissingImports = 1,
ProfileEvaluation = 128,
RecordDuplicateButNotCircularImports = 2,
RecordEvaluatedItemElements = 8,
RejectCircularImports = 4,
Expand Down Expand Up @@ -965,6 +973,7 @@ public BuildParameters(Microsoft.Build.Evaluation.ProjectCollection projectColle
public int MemoryUseLimit { get { throw null; } set { } }
public string NodeExeLocation { get { throw null; } set { } }
public bool OnlyLogCriticalEvents { get { throw null; } set { } }
public Microsoft.Build.Evaluation.ProjectLoadSettings ProjectLoadSettings { get { throw null; } set { } }
public bool ResetCaches { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public bool SaveOperatingEnvironment { get { throw null; } set { } }
public bool ShutdownInProcNodeOnBuildFinish { get { throw null; } set { } }
Expand Down Expand Up @@ -1532,6 +1541,15 @@ public LoggerDescription(string loggerClassName, string loggerAssemblyName, stri
public Microsoft.Build.Framework.LoggerVerbosity Verbosity { get { throw null; } }
public Microsoft.Build.Framework.ILogger CreateLogger() { throw null; }
}
public sealed partial class ProfilerLogger : Microsoft.Build.Framework.ILogger
{
public ProfilerLogger(string fileToLog) { }
public string FileToLog { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Parameters { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public Microsoft.Build.Framework.LoggerVerbosity Verbosity { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public void Initialize(Microsoft.Build.Framework.IEventSource eventSource) { }
public void Shutdown() { }
}
public delegate void WriteHandler(string message);
}
namespace Microsoft.VisualStudio.Setup.Configuration
Expand Down
Loading