Skip to content

Commit 19a197e

Browse files
SteveSandersonMSpranavkm
authored andcommitted
Remove Blazor internal profiling infrastructure (#24468)
* Put back InternalCalls * Removing .NET profiling calls * Remove JS side profiling
1 parent fcabe6f commit 19a197e

18 files changed

+5
-373
lines changed

src/Components/Components/src/Microsoft.AspNetCore.Components.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<ItemGroup>
1212
<Compile Include="$(ComponentsSharedSourceRoot)src\ArrayBuilder.cs" LinkBase="RenderTree" />
13-
<Compile Include="$(ComponentsSharedSourceRoot)src\WebAssemblyJSInteropInternalCalls.cs" />
1413
</ItemGroup>
1514

1615
<ItemGroup>

src/Components/Components/src/Profiling/ComponentsProfiling.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Components/Components/src/Profiling/NoOpComponentsProfiling.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Components/Components/src/Profiling/WebAssemblyComponentsProfiling.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/Components/Components/src/RenderTree/RenderTreeDiffBuilder.cs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Collections.Generic;
88
using System.Diagnostics;
99
using System.Runtime.CompilerServices;
10-
using Microsoft.AspNetCore.Components.Profiling;
1110
using Microsoft.AspNetCore.Components.Rendering;
1211

1312
namespace Microsoft.AspNetCore.Components.RenderTree
@@ -28,7 +27,6 @@ public static RenderTreeDiff ComputeDiff(
2827
ArrayRange<RenderTreeFrame> oldTree,
2928
ArrayRange<RenderTreeFrame> newTree)
3029
{
31-
ComponentsProfiling.Instance.Start();
3230
var editsBuffer = batchBuilder.EditsBuffer;
3331
var editsBufferStartLength = editsBuffer.Count;
3432

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

3836
var editsSegment = editsBuffer.ToSegment(editsBufferStartLength, editsBuffer.Count);
3937
var result = new RenderTreeDiff(componentId, editsSegment);
40-
ComponentsProfiling.Instance.End();
4138
return result;
4239
}
4340

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

306301
private static Dictionary<object, KeyedItemInfo> BuildKeyToInfoLookup(DiffContext diffContext, int oldStartIndex, int oldEndIndexExcl, int newStartIndex, int newEndIndexExcl)
307302
{
308-
ProfilingStart();
309303
var result = diffContext.KeyedItemInfoDictionaryPool.Get();
310304
var oldTree = diffContext.OldTree;
311305
var newTree = diffContext.NewTree;
@@ -351,7 +345,6 @@ private static Dictionary<object, KeyedItemInfo> BuildKeyToInfoLookup(DiffContex
351345
newStartIndex = NextSiblingIndex(frame, newStartIndex);
352346
}
353347

354-
ProfilingEnd();
355348
return result;
356349
}
357350

@@ -384,7 +377,6 @@ private static void AppendAttributeDiffEntriesForRange(
384377
int oldStartIndex, int oldEndIndexExcl,
385378
int newStartIndex, int newEndIndexExcl)
386379
{
387-
ProfilingStart();
388380
// The overhead of the dictionary used by AppendAttributeDiffEntriesForRangeSlow is
389381
// significant, so we want to try and do a merge-join if possible, but fall back to
390382
// a hash-join if not. We'll do a merge join until we hit a case we can't handle and
@@ -433,7 +425,6 @@ private static void AppendAttributeDiffEntriesForRange(
433425
ref diffContext,
434426
oldStartIndex, oldEndIndexExcl,
435427
newStartIndex, newEndIndexExcl);
436-
ProfilingEnd();
437428
return;
438429
}
439430

@@ -459,20 +450,16 @@ private static void AppendAttributeDiffEntriesForRange(
459450
ref diffContext,
460451
oldStartIndex, oldEndIndexExcl,
461452
newStartIndex, newEndIndexExcl);
462-
ProfilingEnd();
463453
return;
464454
}
465455
}
466-
467-
ProfilingEnd();
468456
}
469457

470458
private static void AppendAttributeDiffEntriesForRangeSlow(
471459
ref DiffContext diffContext,
472460
int oldStartIndex, int oldEndIndexExcl,
473461
int newStartIndex, int newEndIndexExcl)
474462
{
475-
ProfilingStart();
476463
var oldTree = diffContext.OldTree;
477464
var newTree = diffContext.NewTree;
478465

@@ -511,15 +498,13 @@ private static void AppendAttributeDiffEntriesForRangeSlow(
511498

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

517503
private static void UpdateRetainedChildComponent(
518504
ref DiffContext diffContext,
519505
int oldComponentIndex,
520506
int newComponentIndex)
521507
{
522-
ProfilingStart();
523508
var oldTree = diffContext.OldTree;
524509
var newTree = diffContext.NewTree;
525510
ref var oldComponentFrame = ref oldTree[oldComponentIndex];
@@ -546,8 +531,6 @@ private static void UpdateRetainedChildComponent(
546531
{
547532
componentState.SetDirectParameters(newParameters);
548533
}
549-
550-
ProfilingEnd();
551534
}
552535

553536
private static int NextSiblingIndex(in RenderTreeFrame frame, int frameIndex)
@@ -570,7 +553,6 @@ private static void AppendDiffEntriesForFramesWithSameSequence(
570553
int oldFrameIndex,
571554
int newFrameIndex)
572555
{
573-
ProfilingStart();
574556
var oldTree = diffContext.OldTree;
575557
var newTree = diffContext.NewTree;
576558
ref var oldFrame = ref oldTree[oldFrameIndex];
@@ -583,7 +565,6 @@ private static void AppendDiffEntriesForFramesWithSameSequence(
583565
{
584566
InsertNewFrame(ref diffContext, newFrameIndex);
585567
RemoveOldFrame(ref diffContext, oldFrameIndex);
586-
ProfilingEnd();
587568
return;
588569
}
589570

@@ -709,8 +690,6 @@ private static void AppendDiffEntriesForFramesWithSameSequence(
709690
default:
710691
throw new NotImplementedException($"Encountered unsupported frame type during diffing: {newTree[newFrameIndex].FrameType}");
711692
}
712-
713-
ProfilingEnd();
714693
}
715694

716695
// This should only be called for attributes that have the same name. This is an
@@ -720,7 +699,6 @@ private static void AppendDiffEntriesForAttributeFrame(
720699
int oldFrameIndex,
721700
int newFrameIndex)
722701
{
723-
ProfilingStart();
724702
var oldTree = diffContext.OldTree;
725703
var newTree = diffContext.NewTree;
726704
ref var oldFrame = ref oldTree[oldFrameIndex];
@@ -749,13 +727,10 @@ private static void AppendDiffEntriesForAttributeFrame(
749727
// since it was unchanged.
750728
newFrame = oldFrame;
751729
}
752-
753-
ProfilingEnd();
754730
}
755731

756732
private static void InsertNewFrame(ref DiffContext diffContext, int newFrameIndex)
757733
{
758-
ProfilingStart();
759734
var newTree = diffContext.NewTree;
760735
ref var newFrame = ref newTree[newFrameIndex];
761736
switch (newFrame.FrameType)
@@ -808,12 +783,10 @@ private static void InsertNewFrame(ref DiffContext diffContext, int newFrameInde
808783
default:
809784
throw new NotImplementedException($"Unexpected frame type during {nameof(InsertNewFrame)}: {newFrame.FrameType}");
810785
}
811-
ProfilingEnd();
812786
}
813787

814788
private static void RemoveOldFrame(ref DiffContext diffContext, int oldFrameIndex)
815789
{
816-
ProfilingStart();
817790
var oldTree = diffContext.OldTree;
818791
ref var oldFrame = ref oldTree[oldFrameIndex];
819792
switch (oldFrame.FrameType)
@@ -855,7 +828,6 @@ private static void RemoveOldFrame(ref DiffContext diffContext, int oldFrameInde
855828
default:
856829
throw new NotImplementedException($"Unexpected frame type during {nameof(RemoveOldFrame)}: {oldFrame.FrameType}");
857830
}
858-
ProfilingEnd();
859831
}
860832

861833
private static int GetAttributesEndIndexExclusive(RenderTreeFrame[] tree, int rootIndex)
@@ -889,7 +861,6 @@ private static void AppendStepOut(ref DiffContext diffContext)
889861

890862
private static void InitializeNewSubtree(ref DiffContext diffContext, int frameIndex)
891863
{
892-
ProfilingStart();
893864
var frames = diffContext.NewTree;
894865
var endIndexExcl = frameIndex + frames[frameIndex].ElementSubtreeLength;
895866
for (var i = frameIndex; i < endIndexExcl; i++)
@@ -911,12 +882,10 @@ private static void InitializeNewSubtree(ref DiffContext diffContext, int frameI
911882
break;
912883
}
913884
}
914-
ProfilingEnd();
915885
}
916886

917887
private static void InitializeNewComponentFrame(ref DiffContext diffContext, int frameIndex)
918888
{
919-
ProfilingStart();
920889
var frames = diffContext.NewTree;
921890
ref var frame = ref frames[frameIndex];
922891

@@ -933,7 +902,6 @@ private static void InitializeNewComponentFrame(ref DiffContext diffContext, int
933902
var initialParametersLifetime = new ParameterViewLifetime(diffContext.BatchBuilder);
934903
var initialParameters = new ParameterView(initialParametersLifetime, frames, frameIndex);
935904
childComponentState.SetDirectParameters(initialParameters);
936-
ProfilingEnd();
937905
}
938906

939907
private static void InitializeNewAttributeFrame(ref DiffContext diffContext, ref RenderTreeFrame newFrame)
@@ -978,7 +946,6 @@ private static void InitializeNewComponentReferenceCaptureFrame(ref DiffContext
978946

979947
private static void DisposeFramesInRange(RenderBatchBuilder batchBuilder, RenderTreeFrame[] frames, int startIndex, int endIndexExcl)
980948
{
981-
ProfilingStart();
982949
for (var i = startIndex; i < endIndexExcl; i++)
983950
{
984951
ref var frame = ref frames[i];
@@ -991,7 +958,6 @@ private static void DisposeFramesInRange(RenderBatchBuilder batchBuilder, Render
991958
batchBuilder.DisposedEventHandlerIds.Append(frame.AttributeEventHandlerId);
992959
}
993960
}
994-
ProfilingEnd();
995961
}
996962

997963
/// <summary>
@@ -1033,18 +999,5 @@ public DiffContext(
1033999
SiblingIndex = 0;
10341000
}
10351001
}
1036-
1037-
// Having too many calls to ComponentsProfiling.Instance.Start/End has a measurable perf impact
1038-
// even when capturing is disabled. So, to enable detailed profiling for this class, define the
1039-
// Profile_RenderTreeDiffBuilder compiler symbol, otherwise the calls are compiled out entirely.
1040-
// Enabling detailed profiling adds about 5% to rendering benchmark times.
1041-
1042-
[Conditional("Profile_RenderTreeDiffBuilder")]
1043-
private static void ProfilingStart([CallerMemberName] string? name = null)
1044-
=> ComponentsProfiling.Instance.Start(name);
1045-
1046-
[Conditional("Profile_RenderTreeDiffBuilder")]
1047-
private static void ProfilingEnd([CallerMemberName] string? name = null)
1048-
=> ComponentsProfiling.Instance.End(name);
10491002
}
10501003
}

0 commit comments

Comments
 (0)