Skip to content

Remove Blazor internal profiling infrastructure #24468

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

Merged
merged 3 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

<ItemGroup>
<Compile Include="$(ComponentsSharedSourceRoot)src\ArrayBuilder.cs" LinkBase="RenderTree" />
<Compile Include="$(ComponentsSharedSourceRoot)src\WebAssemblyJSInteropInternalCalls.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 0 additions & 23 deletions src/Components/Components/src/Profiling/ComponentsProfiling.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Components/Components/src/Profiling/NoOpComponentsProfiling.cs

This file was deleted.

This file was deleted.

47 changes: 0 additions & 47 deletions src/Components/Components/src/RenderTree/RenderTreeDiffBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Components.Profiling;
using Microsoft.AspNetCore.Components.Rendering;

namespace Microsoft.AspNetCore.Components.RenderTree
Expand All @@ -28,7 +27,6 @@ public static RenderTreeDiff ComputeDiff(
ArrayRange<RenderTreeFrame> oldTree,
ArrayRange<RenderTreeFrame> newTree)
{
ComponentsProfiling.Instance.Start();
var editsBuffer = batchBuilder.EditsBuffer;
var editsBufferStartLength = editsBuffer.Count;

Expand All @@ -37,7 +35,6 @@ public static RenderTreeDiff ComputeDiff(

var editsSegment = editsBuffer.ToSegment(editsBufferStartLength, editsBuffer.Count);
var result = new RenderTreeDiff(componentId, editsSegment);
ComponentsProfiling.Instance.End();
return result;
}

Expand All @@ -49,7 +46,6 @@ private static void AppendDiffEntriesForRange(
int oldStartIndex, int oldEndIndexExcl,
int newStartIndex, int newEndIndexExcl)
{
ProfilingStart();
// This is deliberately a very large method. Parts of it could be factored out
// into other private methods, but doing so comes at a consequential perf cost,
// because it involves so much parameter passing. You can think of the code here
Expand Down Expand Up @@ -300,12 +296,10 @@ private static void AppendDiffEntriesForRange(
diffContext.KeyedItemInfoDictionaryPool.Return(keyedItemInfos);
}
}
ProfilingEnd();
}

private static Dictionary<object, KeyedItemInfo> BuildKeyToInfoLookup(DiffContext diffContext, int oldStartIndex, int oldEndIndexExcl, int newStartIndex, int newEndIndexExcl)
{
ProfilingStart();
var result = diffContext.KeyedItemInfoDictionaryPool.Get();
var oldTree = diffContext.OldTree;
var newTree = diffContext.NewTree;
Expand Down Expand Up @@ -351,7 +345,6 @@ private static Dictionary<object, KeyedItemInfo> BuildKeyToInfoLookup(DiffContex
newStartIndex = NextSiblingIndex(frame, newStartIndex);
}

ProfilingEnd();
return result;
}

Expand Down Expand Up @@ -394,7 +387,6 @@ private static void AppendAttributeDiffEntriesForRange(
int oldStartIndex, int oldEndIndexExcl,
int newStartIndex, int newEndIndexExcl)
{
ProfilingStart();
// The overhead of the dictionary used by AppendAttributeDiffEntriesForRangeSlow is
// significant, so we want to try and do a merge-join if possible, but fall back to
// a hash-join if not. We'll do a merge join until we hit a case we can't handle and
Expand Down Expand Up @@ -443,7 +435,6 @@ private static void AppendAttributeDiffEntriesForRange(
ref diffContext,
oldStartIndex, oldEndIndexExcl,
newStartIndex, newEndIndexExcl);
ProfilingEnd();
return;
}

Expand All @@ -469,20 +460,16 @@ private static void AppendAttributeDiffEntriesForRange(
ref diffContext,
oldStartIndex, oldEndIndexExcl,
newStartIndex, newEndIndexExcl);
ProfilingEnd();
return;
}
}

ProfilingEnd();
}

private static void AppendAttributeDiffEntriesForRangeSlow(
ref DiffContext diffContext,
int oldStartIndex, int oldEndIndexExcl,
int newStartIndex, int newEndIndexExcl)
{
ProfilingStart();
var oldTree = diffContext.OldTree;
var newTree = diffContext.NewTree;

Expand Down Expand Up @@ -521,15 +508,13 @@ private static void AppendAttributeDiffEntriesForRangeSlow(

// We should have processed any additions at this point. Reset for the next batch.
diffContext.AttributeDiffSet.Clear();
ProfilingEnd();
}

private static void UpdateRetainedChildComponent(
ref DiffContext diffContext,
int oldComponentIndex,
int newComponentIndex)
{
ProfilingStart();
var oldTree = diffContext.OldTree;
var newTree = diffContext.NewTree;
ref var oldComponentFrame = ref oldTree[oldComponentIndex];
Expand All @@ -556,8 +541,6 @@ private static void UpdateRetainedChildComponent(
{
componentState.SetDirectParameters(newParameters);
}

ProfilingEnd();
}

private static int NextSiblingIndex(in RenderTreeFrame frame, int frameIndex)
Expand All @@ -580,7 +563,6 @@ private static void AppendDiffEntriesForFramesWithSameSequence(
int oldFrameIndex,
int newFrameIndex)
{
ProfilingStart();
var oldTree = diffContext.OldTree;
var newTree = diffContext.NewTree;
ref var oldFrame = ref oldTree[oldFrameIndex];
Expand All @@ -593,7 +575,6 @@ private static void AppendDiffEntriesForFramesWithSameSequence(
{
InsertNewFrame(ref diffContext, newFrameIndex);
RemoveOldFrame(ref diffContext, oldFrameIndex);
ProfilingEnd();
return;
}

Expand Down Expand Up @@ -719,8 +700,6 @@ private static void AppendDiffEntriesForFramesWithSameSequence(
default:
throw new NotImplementedException($"Encountered unsupported frame type during diffing: {newTree[newFrameIndex].FrameType}");
}

ProfilingEnd();
}

// This should only be called for attributes that have the same name. This is an
Expand All @@ -730,7 +709,6 @@ private static void AppendDiffEntriesForAttributeFrame(
int oldFrameIndex,
int newFrameIndex)
{
ProfilingStart();
var oldTree = diffContext.OldTree;
var newTree = diffContext.NewTree;
ref var oldFrame = ref oldTree[oldFrameIndex];
Expand Down Expand Up @@ -759,13 +737,10 @@ private static void AppendDiffEntriesForAttributeFrame(
// since it was unchanged.
newFrame = oldFrame;
}

ProfilingEnd();
}

private static void InsertNewFrame(ref DiffContext diffContext, int newFrameIndex)
{
ProfilingStart();
var newTree = diffContext.NewTree;
ref var newFrame = ref newTree[newFrameIndex];
switch (newFrame.FrameType)
Expand Down Expand Up @@ -818,12 +793,10 @@ private static void InsertNewFrame(ref DiffContext diffContext, int newFrameInde
default:
throw new NotImplementedException($"Unexpected frame type during {nameof(InsertNewFrame)}: {newFrame.FrameType}");
}
ProfilingEnd();
}

private static void RemoveOldFrame(ref DiffContext diffContext, int oldFrameIndex)
{
ProfilingStart();
var oldTree = diffContext.OldTree;
ref var oldFrame = ref oldTree[oldFrameIndex];
switch (oldFrame.FrameType)
Expand Down Expand Up @@ -865,7 +838,6 @@ private static void RemoveOldFrame(ref DiffContext diffContext, int oldFrameInde
default:
throw new NotImplementedException($"Unexpected frame type during {nameof(RemoveOldFrame)}: {oldFrame.FrameType}");
}
ProfilingEnd();
}

private static int GetAttributesEndIndexExclusive(RenderTreeFrame[] tree, int rootIndex)
Expand Down Expand Up @@ -899,7 +871,6 @@ private static void AppendStepOut(ref DiffContext diffContext)

private static void InitializeNewSubtree(ref DiffContext diffContext, int frameIndex)
{
ProfilingStart();
var frames = diffContext.NewTree;
var endIndexExcl = frameIndex + frames[frameIndex].ElementSubtreeLength;
for (var i = frameIndex; i < endIndexExcl; i++)
Expand All @@ -921,12 +892,10 @@ private static void InitializeNewSubtree(ref DiffContext diffContext, int frameI
break;
}
}
ProfilingEnd();
}

private static void InitializeNewComponentFrame(ref DiffContext diffContext, int frameIndex)
{
ProfilingStart();
var frames = diffContext.NewTree;
ref var frame = ref frames[frameIndex];

Expand All @@ -943,7 +912,6 @@ private static void InitializeNewComponentFrame(ref DiffContext diffContext, int
var initialParametersLifetime = new ParameterViewLifetime(diffContext.BatchBuilder);
var initialParameters = new ParameterView(initialParametersLifetime, frames, frameIndex);
childComponentState.SetDirectParameters(initialParameters);
ProfilingEnd();
}

private static void InitializeNewAttributeFrame(ref DiffContext diffContext, ref RenderTreeFrame newFrame)
Expand Down Expand Up @@ -988,7 +956,6 @@ private static void InitializeNewComponentReferenceCaptureFrame(ref DiffContext

private static void DisposeFramesInRange(RenderBatchBuilder batchBuilder, RenderTreeFrame[] frames, int startIndex, int endIndexExcl)
{
ProfilingStart();
for (var i = startIndex; i < endIndexExcl; i++)
{
ref var frame = ref frames[i];
Expand All @@ -1001,7 +968,6 @@ private static void DisposeFramesInRange(RenderBatchBuilder batchBuilder, Render
batchBuilder.DisposedEventHandlerIds.Append(frame.AttributeEventHandlerId);
}
}
ProfilingEnd();
}

/// <summary>
Expand Down Expand Up @@ -1043,18 +1009,5 @@ public DiffContext(
SiblingIndex = 0;
}
}

// Having too many calls to ComponentsProfiling.Instance.Start/End has a measurable perf impact
// even when capturing is disabled. So, to enable detailed profiling for this class, define the
// Profile_RenderTreeDiffBuilder compiler symbol, otherwise the calls are compiled out entirely.
// Enabling detailed profiling adds about 5% to rendering benchmark times.

[Conditional("Profile_RenderTreeDiffBuilder")]
private static void ProfilingStart([CallerMemberName] string? name = null)
=> ComponentsProfiling.Instance.Start(name);

[Conditional("Profile_RenderTreeDiffBuilder")]
private static void ProfilingEnd([CallerMemberName] string? name = null)
=> ComponentsProfiling.Instance.End(name);
}
}
Loading