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

Cap node processing at 10mil and log issue #3628

Merged
merged 5 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Cap node processing at 10mil and log issue
  • Loading branch information
hoyosjs committed Jan 31, 2023
commit ea5a8c3404c94e6a5a73f3237458bcc645418acc
4 changes: 2 additions & 2 deletions src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ internal static bool TryCollectMemoryGraph(CancellationToken ct, int processId,
{
var heapInfo = new DotNetHeapInfo();
var log = verbose ? Console.Out : TextWriter.Null;
memoryGraph = new MemoryGraph(50_000);

memoryGraph = new MemoryGraph(expectedSize: 500_000, isVeryLargeGraph: true);
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved

if (!EventPipeDotNetHeapDumper.DumpFromEventPipe(ct, processId, memoryGraph, log, timeout, heapInfo))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ internal unsafe void ConvertHeapDataToGraph()
}

m_converted = true;
const int MaxNodeCount = 10_000_000;

if (!m_seenStart)
{
Expand Down Expand Up @@ -712,11 +713,26 @@ internal unsafe void ConvertHeapDataToGraph()

Debug.Assert(!m_graph.IsDefined(nodeIdx));
m_graph.SetNode(nodeIdx, typeIdx, objSize, m_children);

if (m_graph.NodeCount >= MaxNodeCount)
{
doCompletionCheck = false;
m_log.WriteLine("[WARNING: ]",
$"Exceeded max node count {MaxNodeCount}. Processed {m_curNodeIdx}/{m_curNodeBlock.Count} nodes with {m_nodeBlocks.Count} node bulk events to go.");
break;
}
}

if (doCompletionCheck && m_curEdgeBlock != null && m_curEdgeBlock.Count != m_curEdgeIdx)

if (m_curEdgeBlock != null && m_curEdgeBlock.Count != m_curEdgeIdx)
{
throw new ApplicationException("Error: extra edge data. Giving up on heap dump.");
m_log.WriteLine("[WARNING: ]",
$"Extra edge data found. Processing edge {m_curEdgeIdx}/{m_curEdgeBlock.Count} with {m_edgeBlocks.Count} edge bulk events to go.");

if (doCompletionCheck)
{
throw new ApplicationException("Error: Giving up on heap dump.");
}
}

m_root.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static bool DumpFromEventPipe(CancellationToken ct, int processID, Memory

eventPipeDataPresent = true;

if (gcNum < 0 && data.Depth == 2 && data.Type != GCType.BackgroundGC)
if (gcNum < 0 && data.Depth == 2 && data.Type != GCType.BackgroundGC && data.Reason == GCReason.Induced)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you either update the PR description or remove this part of the change? I can't determine how this part of the change relates.

Copy link
Member Author

@hoyosjs hoyosjs Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it mostly to revert to prior behavior - although this is technically a bug and can cause an early detach from the EP session.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it mostly to revert to prior behavior

I don't know what you mean? GitHub doesn't show the change has been removed in the latest version of your PR? I've still got the same request as before - lets either remove this edit from the PR or add text to summary commit message/PR description saying what issue is being fixed here :)

{
gcNum = data.Count;
log.WriteLine("{0,5:n1}s: .NET Dump Started...", getElapsed().TotalSeconds);
Expand Down
10 changes: 5 additions & 5 deletions src/Tools/dotnet-gcdump/DotNetHeapDump/MemoryGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public MemoryGraph(int expectedSize, bool isVeryLargeGraph = false)
m_addressToNodeIndex = new SegmentedDictionary<Address, NodeIndex>(expectedSize);
}
else
{
m_addressToNodeIndex = new Dictionary<Address, NodeIndex>(expectedSize);
{
m_addressToNodeIndex = new Dictionary<Address, NodeIndex>(expectedSize);
}

m_nodeAddresses = new SegmentedList<Address>(SegmentSize, expectedSize);
}

Expand Down Expand Up @@ -133,13 +133,13 @@ void IFastSerializable.ToStream(Serializer serializer)
// Write out the Memory addresses of each object
if (m_isVeryLargeGraph)
{
serializer.Write(m_nodeAddresses.Count);
serializer.Write(m_nodeAddresses.Count);
}
else
{
serializer.Write((int)m_nodeAddresses.Count);
}

for (int i = 0; i < m_nodeAddresses.Count; i++)
{
serializer.Write((long)m_nodeAddresses[i]);
Expand Down