Memory Diagnostics: GC Bookkeeping - #84454
Conversation
|
Tagging subscribers to this area: @tommcdon Issue DetailsAdds a way for debuggers to tag GC related memory as owned by the CLR. As part of our ongoing work to improve (and fix) native and managed memory diagnostics (dotnet/diagnostics#3736) we need the debugger to be able to find GC-related memory that's been VirtualAlloc'ed. We are specifically seeing a lot of investigations coming in where being able to know what memory regions account for GC bookkeeping data will let us quickly eliminate (or blame) the GC in memory related investigations. GC related changes:
Dac/SOS related changes:
Manual testing looks good so far, so I'm putting this up for code review. I'm marking it NO-MERGE until I've completed more extensive testing.
|
|
This is now fully tested with USE_REGIONS and with segments on both x86 and x64. It all works great! So, this checkin is ready to merge (and ready for review!), but I'm expecting some spirited rounds of debates on some of the changes. =) I attempted to loosen the requirement of pulling in HandleTable constants to the GC/Dac interface by moving HandleTableSegment::pNextSegment to the front of that class/structure. I found that this quickly causes asserts and failures because things take a hard dependency on the layout of handle table segments. If there's pushback to taking a dependency on HANDLE_BLOCKS_PER_SEGMENT/HANDLE_MASKS_PER_SEGMENT like we (already) did with HANDLE_MAX_INTERNAL_TYPES then I can dig in further here. |
|
This is applicable for both regions and segments. I've tested both and it works. For testing, I've done extensive testing of the new debugging APIs for x86 and x64 (which covers Segments and Regions). I set up several small repro programs to get free Regions, as well as testing the multiple card_table case for Segments. I have not done any GC specific testing. If you all could provide some instructions on GC testing I'd be happy to go do that. Otherwise, it's passing standard checkin tests. |
|
@cshung This is ready for final testing/review. I've tested this on x86/x64 (segments/regions) with both workstation and server GC. I was able to set breakpoints in strategic places in the gc to test the various pieces of this change. I also confirmed that the total memory that ClrMD/SOS now reports is equal to the sizes saved by the GC when a hard limit is set. Let me know if you have any other questions, feedback, or if you'd like me to do any other testing. Otherwise this is all ready for final review and checkin whenever you are. Thanks! |
b4fb793 to
59c57f0
Compare
cshung
left a comment
There was a problem hiding this comment.
In general, this change is great, thanks for doing this.
I have made some suggested changes here to the GC code to do some renaming, can you please incorporate the changes?
On that change, I ran the code over the GC infrastructure for validation and found no bugs or regressions. You can see the test report there.
Other comments listed here are just nice to have and non-blocking, this is good to go.
- bookkeeping_covered_start is now compiled into all versions of the GC, instead of just with USE_REGIONS. This allows us to find the base address of the allocated memory for GC Bookkeeping. - Added dac enumeration of GC Bookkeeping.
We should never have missing fields in the dac. This is a leftover from previous code.
When using segments, update bookkeeping_covered_start and card_table_info.size when we update the card table.
Check how many times we loop through memory to guard against heap corruption.
Co-authored-by: Andrew Au <cshung@gmail.com>
49e28be to
9abf2f3
Compare
Adds a way for debuggers to tag GC related memory as owned by the CLR.
As part of our ongoing work to improve (and fix) native and managed memory diagnostics (dotnet/diagnostics#3736) we need the debugger to be able to find GC-related memory that's been VirtualAlloc'ed. We are specifically seeing a lot of investigations coming in where being able to know what memory regions account for GC bookkeeping data will let us quickly eliminate (or blame) the GC in memory related investigations.
GC related changes:
regionswhich have not yet been released.bookkeeping_covered_startto be present in all cases (not just when USE_REGIONS is defined...even though it's not needed for anything other than diagnostics when not using regions). This is the actual memory base we get back from VirtualAlloc, so along with card_table_info we know the entire range of memory that bookkeeping data will fall within.Dac/SOS related changes:
Flush()while under the dac lock. The lack of this is particularly painful for ClrMD, which calls into the dac on multiple threads. (This is unrelated to the rest of the changes.)Manual testing looks good so far, so I'm putting this up for code review. I'm marking it NO-MERGE until I've completed more extensive testing.