Skip to content

Commit

Permalink
Improve GC stress log instrumentation (dotnet#53547)
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung authored Jun 8, 2021
1 parent 54f78b8 commit e42c896
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 252 deletions.
126 changes: 1 addition & 125 deletions src/coreclr/gc/env/gcenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,131 +195,7 @@ enum LogLevel
class ThreadStressLog
{
public:
static const char* gcStartMsg()
{
STATIC_CONTRACT_LEAF;
return "{ =========== BEGINGC %d, (requested generation = %lu, collect_classes = %lu) ==========\n";
}

static const char* gcEndMsg()
{
STATIC_CONTRACT_LEAF;
return "========== ENDGC %d (gen = %lu, collect_classes = %lu) ===========}\n";
}

static const char* gcRootMsg()
{
STATIC_CONTRACT_LEAF;
return " GC Root %p RELOCATED %p -> %p MT = %pT\n";
}

static const char* gcRootPromoteMsg()
{
STATIC_CONTRACT_LEAF;
return " IGCHeap::Promote: Promote GC Root *%p = %p MT = %pT\n";
}

static const char* gcPlugMoveMsg()
{
STATIC_CONTRACT_LEAF;
return "GC_HEAP RELOCATING Objects in heap within range [%p %p) by -0x%x bytes\n";
}

static const char* gcServerThread0StartMsg()
{
STATIC_CONTRACT_LEAF;
return "%d gc thread waiting...";
}

static const char* gcServerThreadNStartMsg()
{
STATIC_CONTRACT_LEAF;
return "%d gc thread waiting... Done";
}

static const char* gcDetailedStartMsg()
{
STATIC_CONTRACT_LEAF;
return "*GC* %d(gen0:%d)(%d)(alloc: %Id)(%s)(%d)";
}

static const char* gcDetailedEndMsg()
{
STATIC_CONTRACT_LEAF;
return "*EGC* %Id(gen0:%Id)(%Id)(%d)(%s)(%s)(%s)(ml: %d->%d)";
}

static const char* gcStartMarkMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Mark Phase on heap %d condemning %d ----";
}

static const char* gcStartPlanMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Plan Phase on heap %d ---- Condemned generation %d, promotion: %d";
}

static const char* gcStartRelocateMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Relocate phase on heap %d -----";
}

static const char* gcEndRelocateMsg()
{
STATIC_CONTRACT_LEAF;
return "---- End of Relocate phase on heap %d ----";
}

static const char* gcStartCompactMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Compact Phase on heap %d: %Ix(%Ix)----";
}

static const char* gcEndCompactMsg()
{
STATIC_CONTRACT_LEAF;
return "---- End of Compact phase on heap %d ----";
}

static const char* gcMemCopyMsg()
{
STATIC_CONTRACT_LEAF;
return " mc: [%Ix->%Ix, %Ix->%Ix[";
}

static const char* gcPlanPlugMsg()
{
STATIC_CONTRACT_LEAF;
return "(%Ix)[%Ix->%Ix, NA: [%Ix(%Id), %Ix[: %Ix(%d), x: %Ix (%s)";
}

static const char* gcPlanPinnedPlugMsg()
{
STATIC_CONTRACT_LEAF;
return "(%Ix)PP: [%Ix, %Ix[%Ix](m:%d)";
}

static const char* gcDesiredNewAllocationMsg()
{
STATIC_CONTRACT_LEAF;
return "h%d g%d surv: %Id current: %Id alloc: %Id (%d%%) f: %d%% new-size: %Id new-alloc: %Id";
}

static const char* gcMakeUnusedArrayMsg()
{
STATIC_CONTRACT_LEAF;
return "Making unused array [%Ix, %Ix[";
}

static const char* gcStartBgcThread()
{
STATIC_CONTRACT_LEAF;
return "beginning of bgc on heap %d: gen2 FL: %d, FO: %d, frag: %d";
}
#include "../../inc/gcmsg.inl"
};

struct StressLogMsg
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29214,6 +29214,7 @@ void gc_heap::relocate_address (uint8_t** pold_address THREAD_NUMBER_DCL)
}
}

dprintf (4, (ThreadStressLog::gcRelocateReferenceMsg(), pold_address, old_address, new_address));
*pold_address = new_address;
return;
}
Expand Down Expand Up @@ -29243,7 +29244,9 @@ void gc_heap::relocate_address (uint8_t** pold_address THREAD_NUMBER_DCL)
#endif
)
{
*pold_address = old_address + loh_node_relocation_distance (old_address);
new_address = old_address + loh_node_relocation_distance (old_address);
dprintf (4, (ThreadStressLog::gcRelocateReferenceMsg(), pold_address, old_address, new_address));
*pold_address = new_address;
}
}
}
Expand Down
132 changes: 132 additions & 0 deletions src/coreclr/inc/gcmsg.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@

static const char* gcStartMsg()
{
STATIC_CONTRACT_LEAF;
return "{ =========== BEGINGC %d, (requested generation = %lu, collect_classes = %lu) ==========\n";
}

static const char* gcEndMsg()
{
STATIC_CONTRACT_LEAF;
return "========== ENDGC %d (gen = %lu, collect_classes = %lu) ===========}\n";
}

static const char* gcRootMsg()
{
STATIC_CONTRACT_LEAF;
return " GC Root %p RELOCATED %p -> %p MT = %pT\n";
}

static const char* gcRootPromoteMsg()
{
STATIC_CONTRACT_LEAF;
return " IGCHeap::Promote: Promote GC Root *%p = %p MT = %pT\n";
}

static const char* gcPlugMoveMsg()
{
STATIC_CONTRACT_LEAF;
return "GC_HEAP RELOCATING Objects in heap within range [%p %p) by -0x%x bytes\n";
}

static const char* gcServerThread0StartMsg()
{
STATIC_CONTRACT_LEAF;
return "%d gc thread waiting...";
}

static const char* gcServerThreadNStartMsg()
{
STATIC_CONTRACT_LEAF;
return "%d gc thread waiting... Done";
}

static const char* gcDetailedStartMsg()
{
STATIC_CONTRACT_LEAF;
return "*GC* %d(gen0:%d)(%d)(alloc: %Id)(%s)(%d)";
}

static const char* gcDetailedEndMsg()
{
STATIC_CONTRACT_LEAF;
return "*EGC* %Id(gen0:%Id)(%Id)(%d)(%s)(%s)(%s)(ml: %d->%d)";
}

static const char* gcStartMarkMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Mark Phase on heap %d condemning %d ----";
}

static const char* gcStartPlanMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Plan Phase on heap %d ---- Condemned generation %d, promotion: %d";
}

static const char* gcStartRelocateMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Relocate phase on heap %d -----";
}

static const char* gcEndRelocateMsg()
{
STATIC_CONTRACT_LEAF;
return "---- End of Relocate phase on heap %d ----";
}

static const char* gcStartCompactMsg()
{
STATIC_CONTRACT_LEAF;
return "---- Compact Phase on heap %d: %Ix(%Ix)----";
}

static const char* gcEndCompactMsg()
{
STATIC_CONTRACT_LEAF;
return "---- End of Compact phase on heap %d ----";
}

static const char* gcMemCopyMsg()
{
STATIC_CONTRACT_LEAF;
return " mc: [%Ix->%Ix, %Ix->%Ix[";
}

static const char* gcPlanPlugMsg()
{
STATIC_CONTRACT_LEAF;
return "(%Ix)[%Ix->%Ix, NA: [%Ix(%Id), %Ix[: %Ix(%d), x: %Ix (%s)";
}

static const char* gcPlanPinnedPlugMsg()
{
STATIC_CONTRACT_LEAF;
return "(%Ix)PP: [%Ix, %Ix[%Ix](m:%d)";
}

static const char* gcDesiredNewAllocationMsg()
{
STATIC_CONTRACT_LEAF;
return "h%d g%d surv: %Id current: %Id alloc: %Id (%d%%) f: %d%% new-size: %Id new-alloc: %Id";
}

static const char* gcMakeUnusedArrayMsg()
{
STATIC_CONTRACT_LEAF;
return "Making unused array [%Ix, %Ix[";
}

static const char* gcStartBgcThread()
{
STATIC_CONTRACT_LEAF;
return "beginning of bgc on heap %d: gen2 FL: %d, FO: %d, frag: %d";
}

static const char* gcRelocateReferenceMsg()
{
STATIC_CONTRACT_LEAF;
return "Relocating reference *(%p) from %p to %p";
}
Loading

0 comments on commit e42c896

Please sign in to comment.