Skip to content

Post-Mortem Native and Managed Heap Diagnostics Improvements #3736

Closed

Description

@leculver

I'm working on a large set of Native and GC heap improvements throughout the dotnet runtime, SOS, ClrMD, PerfView, and ICorDebug (though ICorDebug is mostly bugfixing). I'm using this issue to track the work.

The through lines of this project are:

  1. Make managed and native heap analysis easier and more accurate.
  2. Consolidate a lot of complicated GC logic into ClrMD so that we do not have multiple copies.
  3. Instead of spot-fixing the complicated C++ SOS commands, rewrite them in C# where possible to make them easier to maintain.

ClrMD work:

  • Change ClrHeap to understand multiple gc_heaps instead of hiding this detail
  • Add heap verification code to ClrMD
  • Add ThinLock support, then update !dumpheap
  • Consider adding !analyzeoom related data to ClrMD
  • Improve ObjectSet
  • Improve GCRoot related code in ClrMD
  • Investigate whether Finalizer Queue roots are being properly enumerated by the dac

Requests from the GC team:

  • Add ways to dump specific heaps, segments, or ranges to various SOS commands instead of them being all or nothing.
  • Be more forgiving with SOS commands. E.G. skip heap corruption and keep printing in !dumpheap. Allow for partial ranges, etc.
  • Add Peter Sollich's inter-generational refence analysis to SOS
  • Add the ability to dump segment regions to !maddress (solves the same problem as Maoni's !vadump parsing)

Managed heap related changes and improvements:

  • Improve DML handling, improve TableOutput, make output consistent especially with respect to hex/non hex values
  • Add filtering to various commands to only dump from certain memory ranges, segments, or heaps
  • !eeheap - rewrite based on ClrMD
  • !verifyheap - rewrite based on ClrMD
  • !dumpheap - rewrite based on ClrMD
  • !verifyobj - rewrite based on ClrMD
  • !dumpruntimetypes
  • !gcwhere - rewrite based on ClrMD
  • !listnearobj - rewrite based on ClrMD
  • !gcroot - rewrite based on ClrMD
  • !findroots #3833
  • !objsize - rewrite based on ClrMD
  • !analyzeoom - rewrite based on ClrMD
  • !traverseheap - rewrite based on ClrMD
  • !threadpool - rewrite based on ClrMD
  • !finalizequeue - rewrite based on ClrMD
  • !dumpstackobjects - rewrite based on ClrMD
  • Look into improving cancellation for managed commands.
  • Finish consolidating complicated GC logic into ClrMD, all GC logic from SOS so there's only one place to update. Review and remove dead code from SOS.

Runtime work:

  • Enumerating stack roots is extremely slow. This is due to DacStackReferenceWalker using heap enumeration to resolve interior pointers.
  • ICorDebug doesn't seem to correctly enumerate all loader heaps
  • Add new "VirtualAlloc" region enumeration so we properly find GC heap memory regions in !maddress and !eeheap
  • Look for other places we should enumerate VirtualAlloc regions

Visual Studio work:

  • Improve managed heap diagnostic performance
  • [INVESTIGATE] Can we do more for native memory diagnostics in .Net applications?

Native heap related changes and improvements:

  • Port new native heap analysis commands to SOS - !maddress, !findpointersin, etc
  • Fix issues with enumerating loader heaps in ClrMD and SOS
  • Re-test/clean up maddress after adding new VirtualAlloc region enumeration to the runtime

Type related improvements:

  • [INVESTIGATE] Consider adding new SOS Dac functions for understanding TypeHandle instead of MethodTable. This would allow us to handle generics better in SOS/ClrMD.

Bugs to fix along the way:

Cut, due to time:

Perfview work:

  • [INVESTIGATE] Consider moving memory graph and rooting related features
  • Add well-known native memory allocations kept alive by managed objects to the gcdump object graph.
  • Extend the .gcdump format to include information about native memory regions.

SOS work:

  • [INVESTIGATE] Consider using PerfView's logic instead of how !gcroot works today.
  • [INVESTIGATE] Consider adding a new command to SOS to generate a .gcdump
  • [INVESTIGATE] Consider a new way of unit testing for SOS extension commands.
  • For .Net Core, use PDBs to add more detail to commands, such as when the user sets a GC hard limit
  • Add !gchist command to dump out gc history - consider making this a dac API so ClrMD can use it

ClrMD work:

  • Do card table validation

Activity

  1. added
    enhancement
    on Mar 10, 2023
  2. added this to the 8.0.0 milestone on Mar 10, 2023
  3. self-assigned this
    on Mar 10, 2023
  4. changed the title [-]Native and Managed Heap Improvements[/-] [+]Post-Mortem Native and Managed Heap Improvements[/+] on Mar 17, 2023
  5. changed the title [-]Post-Mortem Native and Managed Heap Improvements[/-] [+]Post-Mortem Native and Managed Heap Diagnostics Improvements[/+] on Mar 17, 2023
  6. added
    Cost:XL
    on Mar 17, 2023
  7. removed
    Cost:XL
    on Apr 11, 2023
  8. leculver commented on May 10, 2023

    @leculver
    ContributorAuthor

    Closing as completed as the only thing left was ClrMD3, which I removed from here since it's tracked by its own issue.

  9. ghost locked as resolved and limited conversation to collaborators on Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions