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

Commit fa2ff58

Browse files
committed
GC ETW fixes. The code for getting data for ETW and perf counter was written by different
folks and was very intertwined. For full CLR we always have both defined but for coreclr perf counters are not enabled so some things for ETW were just 0. Need to make sure when one is not defined the rest are still getting the data they need.
1 parent 8e8f049 commit fa2ff58

File tree

8 files changed

+190
-144
lines changed

8 files changed

+190
-144
lines changed

src/gc/gc.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,10 @@ BOOL gc_heap::verify_pinned_queue_p = FALSE;
24572457

24582458
uint8_t* gc_heap::oldest_pinned_plug = 0;
24592459

2460+
#if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
2461+
size_t gc_heap::num_pinned_objects = 0;
2462+
#endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
2463+
24602464
#ifdef FEATURE_LOH_COMPACTION
24612465
size_t gc_heap::loh_pinned_queue_tos = 0;
24622466

@@ -16360,6 +16364,10 @@ int gc_heap::garbage_collect (int n)
1636016364
settings.reason = gc_trigger_reason;
1636116365
verify_pinned_queue_p = FALSE;
1636216366

16367+
#if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
16368+
num_pinned_objects = 0;
16369+
#endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
16370+
1636316371
#ifdef STRESS_HEAP
1636416372
if (settings.reason == reason_gcstress)
1636516373
{
@@ -19869,10 +19877,30 @@ void gc_heap::pin_object (uint8_t* o, uint8_t** ppObject, uint8_t* low, uint8_t*
1986919877
{
1987019878
fire_etw_pin_object_event(o, ppObject);
1987119879
}
19872-
#endif // FEATURE_EVENT_TRACE
19873-
COUNTER_ONLY(GetPerfCounters().m_GC.cPinnedObj ++);
19880+
#endif // FEATURE_EVENT_TRACE
19881+
19882+
#if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
19883+
num_pinned_objects++;
19884+
#endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
19885+
}
19886+
}
19887+
19888+
#if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
19889+
size_t gc_heap::get_total_pinned_objects()
19890+
{
19891+
#ifdef MULTIPLE_HEAPS
19892+
size_t total_num_pinned_objects = 0;
19893+
for (int i = 0; i < gc_heap::n_heaps; i++)
19894+
{
19895+
gc_heap* hp = gc_heap::g_heaps[i];
19896+
total_num_pinned_objects += hp->num_pinned_objects;
1987419897
}
19898+
return total_num_pinned_objects;
19899+
#else //MULTIPLE_HEAPS
19900+
return num_pinned_objects;
19901+
#endif //MULTIPLE_HEAPS
1987519902
}
19903+
#endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
1987619904

1987719905
void gc_heap::reset_mark_stack ()
1987819906
{

0 commit comments

Comments
 (0)