Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

added a lightweight GC profiling option #22866

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/inc/corprof.idl
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,13 @@ typedef enum

COR_PRF_HIGH_DISABLE_TIERED_COMPILATION = 0x00000008,

COR_PRF_HIGH_BASIC_GC = 0x00000010,

COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,

COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED | COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS,
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED |
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS |
COR_PRF_HIGH_BASIC_GC,

// MONITOR_IMMUTABLE represents all flags that may only be set during initialization.
// Trying to change any of these flags elsewhere will result in a
Expand Down
14 changes: 14 additions & 0 deletions src/inc/profilepriv.inl
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,20 @@ inline BOOL CORProfilerDisableTieredCompilation()
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_DISABLE_TIERED_COMPILATION));
}

inline BOOL CORProfilerTrackBasicGC()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
}
CONTRACTL_END;

return (CORProfilerPresent() &&
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_BASIC_GC));
}

#if defined(PROFILING_SUPPORTED) && !defined(CROSSGEN_COMPILE)

#if defined(FEATURE_PROFAPI_ATTACH_DETACH)
Expand Down
3 changes: 2 additions & 1 deletion src/pal/prebuilt/inc/corprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,9 @@ enum __MIDL___MIDL_itf_corprof_0000_0000_0006
COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED = 0x2,
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS = 0x4,
COR_PRF_HIGH_DISABLE_TIERED_COMPILATION = 0x8,
COR_PRF_HIGH_BASIC_GC = 0x10,
COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = ( COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED | COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS ) ,
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = ( COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED | COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS | COR_PRF_HIGH_BASIC_GC) ,
COR_PRF_HIGH_MONITOR_IMMUTABLE = COR_PRF_HIGH_DISABLE_TIERED_COMPILATION
} COR_PRF_HIGH_MONITOR;

Expand Down
4 changes: 2 additions & 2 deletions src/vm/eetoprofinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6196,7 +6196,7 @@ HRESULT EEToProfInterfaceImpl::GarbageCollectionStarted(int cGenerations, BOOL g
LL_INFO10000,
"**PROF: GarbageCollectionStarted.\n"));

_ASSERTE(!GCHeapUtilities::GetGCHeap()->IsConcurrentGCEnabled());
_ASSERTE(!CORProfilerTrackGC() || !GCHeapUtilities::GetGCHeap()->IsConcurrentGCEnabled());

{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
Expand Down Expand Up @@ -6233,7 +6233,7 @@ HRESULT EEToProfInterfaceImpl::GarbageCollectionFinished()
LL_INFO10000,
"**PROF: GarbageCollectionFinished.\n"));

_ASSERTE(!GCHeapUtilities::GetGCHeap()->IsConcurrentGCEnabled());
_ASSERTE(!CORProfilerTrackGC() || !GCHeapUtilities::GetGCHeap()->IsConcurrentGCEnabled());

{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
Expand Down
9 changes: 8 additions & 1 deletion src/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,17 +742,24 @@ void GCToEEInterface::DiagGCStart(int gen, bool isInduced)
void GCToEEInterface::DiagUpdateGenerationBounds()
{
#ifdef GC_PROFILING
if (CORProfilerTrackGC())
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
UpdateGenerationBounds();
#endif // GC_PROFILING
}

void GCToEEInterface::DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent)
{
#ifdef GC_PROFILING
// We were only doing generation bounds and GC finish callback for non concurrent GCs so
// I am keeping that behavior to not break profilers. But if BasicGC monitoring is enabled
// we will do these for all GCs.
if (!fConcurrent)
{
GCProfileWalkHeap();
}

if (CORProfilerTrackBasicGC() || (!fConcurrent && CORProfilerTrackGC()))
{
DiagUpdateGenerationBounds();
GarbageCollectionFinishedCallback();
}
Expand Down
6 changes: 3 additions & 3 deletions src/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ void __stdcall GarbageCollectionStartedCallback(int generation, BOOL induced)

// Notify the profiler of start of the collection
{
BEGIN_PIN_PROFILER(CORProfilerTrackGC());
BEGIN_PIN_PROFILER(CORProfilerTrackGC() || CORProfilerTrackBasicGC());
BOOL generationCollected[COR_PRF_GC_LARGE_OBJECT_HEAP+1];
if (generation == COR_PRF_GC_GEN_2)
generation = COR_PRF_GC_LARGE_OBJECT_HEAP;
Expand Down Expand Up @@ -718,7 +718,7 @@ void __stdcall GarbageCollectionFinishedCallback()
#ifdef PROFILING_SUPPORTED
// Notify the profiler of end of the collection
{
BEGIN_PIN_PROFILER(CORProfilerTrackGC());
BEGIN_PIN_PROFILER(CORProfilerTrackGC() || CORProfilerTrackBasicGC());
g_profControlBlock.pProfInterface->GarbageCollectionFinished();
END_PIN_PROFILER();
}
Expand Down Expand Up @@ -858,7 +858,7 @@ void __stdcall UpdateGenerationBounds()

#ifdef PROFILING_SUPPORTED
// Notify the profiler of start of the collection
if (CORProfilerTrackGC())
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
{
// generate a new generation table
GenerationTable *newGenerationTable = new (nothrow) GenerationTable();
Expand Down