Enhance heap progress PR: -noprogress flag, deterministic timing tests, literal output assertions#5773
Enhance heap progress PR: -noprogress flag, deterministic timing tests, literal output assertions#5773
Conversation
Commands like verifyheap and dumpheap -stat walk the entire managed heap but produce zero output during the walk, which on large dumps (e.g., 19 GB, 248M objects) can mean 7+ minutes of silence indistinguishable from a hang. Add a ProgressCallback property to HeapWithFilters that fires periodically (default every 10 seconds) during EnumerateFilteredObjects(), reporting bytes scanned vs. total heap size as a percentage. Enable it in: - VerifyHeapCommand (always, since it never streams output) - DumpHeapCommand (when -stat is used, since output is deferred) Extract timing logic into a ProgressReporter helper class with unit tests. Fixes #5760 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d using - Use $(SupportedXUnitTestTargetFrameworks) instead of hard-coded net8.0 - Use $(XUnitVersion) instead of hard-coded xunit 2.9.3 - Remove unused using System.Threading Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…s, literal output assertions Co-authored-by: hoyosjs <19413848+hoyosjs@users.noreply.github.com>
- Move ProgressCallback from HeapWithFilters class property to optional parameter on EnumerateFilteredObjects - Rewrite byte tracking: use obj.Address - segment.Start (16KB threshold, segment start/end callbacks) instead of summing object sizes - Refactor ProgressReporter to be the timed console writer registered as the callback handler (takes Action<string>, exposes Report(long, long)) - Update DumpHeapCommand and VerifyHeapCommand to use new API - Update ProgressReporterTests for new API (7/7 pass) Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com>
Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com>
…e add Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com>
src/Microsoft.Diagnostics.ExtensionCommands/ProgressReporter.cs
Outdated
Show resolved
Hide resolved
…nal in ProgressReporter Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com>
noahfalk
left a comment
There was a problem hiding this comment.
made some changes, looks good to me now
There was a problem hiding this comment.
Pull request overview
This PR enhances heap-enumeration progress reporting in Microsoft.Diagnostics.ExtensionCommands by making it optional via a new command flag, refactoring enumeration progress plumbing, and strengthening unit test assertions for progress output/timing.
Changes:
- Add
-noprogressoption todumpheapandverifyheapto suppress periodic heap-scan progress output. - Refactor
HeapWithFilters.EnumerateFilteredObjectsto accept an optional progress callback and track progress using segment-relative address advancement plus end-of-segment reporting. - Introduce
ProgressReporterand add new unit tests validating literal progress output and deterministic timing behavior.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Diagnostics.ExtensionCommands/HeapWithFilters.cs | Adds optional progress callback parameter and new byte-progress tracking logic during enumeration. |
| src/Microsoft.Diagnostics.ExtensionCommands/ProgressReporter.cs | New helper that time-gates formatted progress output. |
| src/Microsoft.Diagnostics.ExtensionCommands/DumpHeapCommand.cs | Adds -noprogress and wires progress reporter for dumpheap -stat. |
| src/Microsoft.Diagnostics.ExtensionCommands/VerifyHeapCommand.cs | Adds -noprogress and wires progress reporter for verifyheap. |
| src/Microsoft.Diagnostics.ExtensionCommands/Microsoft.Diagnostics.ExtensionCommands.csproj | Exposes internals to the new unit test assembly. |
| src/tests/Microsoft.Diagnostics.ExtensionCommands.UnitTests/Microsoft.Diagnostics.ExtensionCommands.UnitTests.csproj | New unit test project for progress reporter tests. |
| src/tests/Microsoft.Diagnostics.ExtensionCommands.UnitTests/ProgressReporterTests.cs | New tests with literal output assertions and deterministic timing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/tests/Microsoft.Diagnostics.ExtensionCommands.UnitTests/ProgressReporterTests.cs
Show resolved
Hide resolved
|
@copilot - please address the code review feedback |
…re progress tracking Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/diagnostics/sessions/883cf807-18c2-4166-a1a6-b7053a396eda
Done in 045404d:
|
|
@copilot - please remove the change you made for memory range filtering. It adds unnecessary complexity and the progress tracking was sufficient for our needs prior to your change. |
Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/diagnostics/sessions/b38a3eb3-fb75-4817-a599-4d128620ba31
Done in 944eca0 — removed the |
ProgressCallbackas optional method parameter onEnumerateFilteredObjects(remove fromHeapWithFiltersclass property)EnumerateFilteredObjectsto use segment position (obj.Address - segment.Start, 16KB threshold, segment start/end callbacks)ProgressReporterto be the timed console writer registered as callback (takesAction<string>writeMessage, receives(scannedBytes, totalBytes)viaReportmethod)DumpHeapCommandandVerifyHeapCommandto use new APIProgressReporterTeststo match newProgressReporterAPI (7/7 tests pass)Original prompt
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.