Skip to content

Commit 7586491

Browse files
committed
Support disabling event tracing
1 parent cd1657d commit 7586491

File tree

18 files changed

+140
-8
lines changed

18 files changed

+140
-8
lines changed

src/coreclr/clr.featuredefines.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<DefineConstants Condition="'$(FeatureCominteropApartmentSupport)' == 'true'">$(DefineConstants);FEATURE_COMINTEROP_APARTMENT_SUPPORT</DefineConstants>
3434
<DefineConstants Condition="'$(FeatureIjw)' == 'true'">$(DefineConstants);FEATURE_IJW</DefineConstants>
3535
<DefineConstants Condition="'$(FeatureObjCMarshal)' == 'true'">$(DefineConstants);FEATURE_OBJCMARSHAL</DefineConstants>
36+
<DefineConstants Condition="'$(FeatureEventTrace)' == 'true'">$(DefineConstants);FEATURE_EVENT_TRACE</DefineConstants>
3637
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">$(DefineConstants);FEATURE_PERFTRACING</DefineConstants>
3738
<DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
3839
<DefineConstants Condition="'$(FeatureTypeEquivalence)' == 'true'">$(DefineConstants);FEATURE_TYPEEQUIVALENCE</DefineConstants>

src/coreclr/clrfeatures.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
33
endif()
44

55
if(NOT DEFINED FEATURE_EVENT_TRACE)
6+
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
67
set(FEATURE_EVENT_TRACE 1)
78
endif(NOT DEFINED FEATURE_EVENT_TRACE)
89

src/coreclr/dlls/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
if(CLR_CMAKE_TARGET_WIN32)
1+
if(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
22
add_subdirectory(clretwrc)
3-
endif(CLR_CMAKE_TARGET_WIN32)
3+
endif(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
44
if (NOT (CLR_CMAKE_TARGET_WIN32 AND FEATURE_CROSSBITNESS))
55
add_subdirectory(mscordbi)
66
add_subdirectory(mscordac)

src/coreclr/gc/gc.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25904,6 +25904,7 @@ void gc_heap::calculate_new_heap_count ()
2590425904
mb (total_soh_stable_size), mb (total_bcd), diff_pct, change_int, (change_int * 100.0 / n_heaps)));
2590525905
}
2590625906

25907+
#ifdef FEATURE_EVENT_TRACE
2590725908
GCEventFireSizeAdaptationTuning_V1 (
2590825909
(uint16_t)new_n_heaps,
2590925910
(uint16_t)max_heap_count_datas,
@@ -25922,6 +25923,7 @@ void gc_heap::calculate_new_heap_count ()
2592225923
(uint16_t)hc_change_freq_factor,
2592325924
(uint16_t)hc_freq_reason,
2592425925
(uint8_t)adj_metric);
25926+
#endif //FEATURE_EVENT_TRACE
2592525927
}
2592625928

2592725929
size_t num_gen2s_since_last_change = 0;
@@ -25977,6 +25979,7 @@ void gc_heap::calculate_new_heap_count ()
2597725979
if (process_gen2_samples_p)
2597825980
{
2597925981
dynamic_heap_count_data_t::gen2_sample* gen2_samples = dynamic_heap_count_data.gen2_samples;
25982+
#ifdef FEATURE_EVENT_TRACE
2598025983
GCEventFireSizeAdaptationFullGCTuning_V1 (
2598125984
(uint16_t)dynamic_heap_count_data.new_n_heaps,
2598225985
(uint64_t)current_gc_index,
@@ -25988,6 +25991,7 @@ void gc_heap::calculate_new_heap_count ()
2598825991
(float)gen2_samples[1].gc_percent,
2598925992
(uint32_t)(current_gc_index - gen2_samples[2].gc_index),
2599025993
(float)gen2_samples[2].gc_percent);
25994+
#endif //FEATURE_EVENT_TRACEs
2599125995

2599225996
dprintf (6666, ("processed gen2 samples, updating processed %Id -> %Id", dynamic_heap_count_data.processed_gen2_samples_count, dynamic_heap_count_data.current_gen2_samples_count));
2599325997
dynamic_heap_count_data.processed_gen2_samples_count = dynamic_heap_count_data.current_gen2_samples_count;
@@ -26683,12 +26687,14 @@ void gc_heap::process_datas_sample()
2668326687
(sample.gc_pause_time ? (sample.gc_survived_size / 1000.0 / sample.gc_pause_time) : 0),
2668426688
(sample.gc_pause_time ? ((float)sample.gc_survived_size / sample.gc_pause_time / n_heaps) : 0)));
2668526689

26690+
#ifdef FEATURE_EVENT_TRACE
2668626691
GCEventFireSizeAdaptationSample_V1 (
2668726692
(uint64_t)gc_index,
2668826693
(uint32_t)sample.elapsed_between_gcs,
2668926694
(uint32_t)sample.gc_pause_time,
2669026695
(uint32_t)soh_msl_wait_time, (uint32_t)uoh_msl_wait_time,
2669126696
(uint64_t)total_soh_stable_size, (uint32_t)sample.gen0_budget_per_heap);
26697+
#endif //FEATURE_EVENT_TRACE
2669226698

2669326699
dynamic_heap_count_data.sample_index = (dynamic_heap_count_data.sample_index + 1) % dynamic_heap_count_data_t::sample_size;
2669426700
(dynamic_heap_count_data.current_samples_count)++;

src/coreclr/inc/profilepriv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#ifndef _ProfilePriv_h_
1414
#define _ProfilePriv_h_
1515

16+
#ifndef FEATURE_PERFTRACING
17+
typedef struct _EventPipeProvider EventPipeProvider;
18+
#endif //FEATURE_PERFTRACING
1619

1720
// Forward declarations
1821
class EEToProfInterfaceImpl;

src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,11 @@
583583
<Compile Include="@(EventingSourceFile)" />
584584
</ItemGroup>
585585

586+
<PropertyGroup>
587+
<FeatureEventTrace>true</FeatureEventTrace>
588+
<DefineConstants Condition="'$(FeatureEventTrace)' == 'true'">$(DefineConstants);FEATURE_EVENT_TRACE</DefineConstants>
589+
</PropertyGroup>
590+
586591
<Target Name="GenerateEventingFiles"
587592
Inputs="@(EventingGenerationScript);@(EventManifestFile);@(EventingInclusionList)"
588593
Outputs="@(EventingSourceFile)"

src/coreclr/vm/finalizerthread.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,12 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
294294
gcGenAnalysisState = GcGenAnalysisState::Disabled;
295295
if (gcGenAnalysisTrace)
296296
{
297+
#ifdef FEATURE_EVENT_TRACE
297298
EventPipeAdapter::Disable(gcGenAnalysisEventPipeSessionId);
298299
#ifdef GEN_ANALYSIS_STRESS
299300
GenAnalysis::EnableGenerationalAwareSession();
300-
#endif
301+
#endif //GEN_ANALYSIS_STRESS
302+
#endif //FEATURE_EVENT_TRACE
301303
}
302304

303305
// Writing an empty file to indicate completion

src/coreclr/vm/gcenv.ee.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,7 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
17241724
{
17251725
if (gcGenAnalysisTrace)
17261726
{
1727+
#ifdef FEATURE_EVENT_TRACE
17271728
EventPipeAdapter::ResumeSession(gcGenAnalysisEventPipeSession);
17281729
FireEtwGenAwareBegin((int)gcIndex, GetClrInstanceId());
17291730
s_forcedGCInProgress = true;
@@ -1732,6 +1733,7 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
17321733
reportGenerationBounds();
17331734
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
17341735
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
1736+
#endif //FEATURE_EVENT_TRACE
17351737
}
17361738
if (gcGenAnalysisDump)
17371739
{

src/coreclr/vm/gchelpers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ inline void CheckObjectSize(size_t alloc_size)
185185

186186
void FireAllocationSampled(GC_ALLOC_FLAGS flags, size_t size, size_t samplingBudgetOffset, Object* orObject)
187187
{
188+
#ifdef FEATURE_EVENT_TRACE
188189
// Note: this code is duplicated from GCToCLREventSink::FireGCAllocationTick_V4
189190
void* typeId = nullptr;
190191
const WCHAR* name = nullptr;
@@ -212,6 +213,7 @@ void FireAllocationSampled(GC_ALLOC_FLAGS flags, size_t size, size_t samplingBud
212213
0; // SOH
213214
FireEtwAllocationSampled(allocKind, GetClrInstanceId(), typeId, name, (BYTE*)orObject, size, samplingBudgetOffset);
214215
}
216+
#endif //FEATURE_EVENT_TRACE
215217
}
216218

217219
inline Object* Alloc(ee_alloc_context* pEEAllocContext, size_t size, GC_ALLOC_FLAGS flags)

src/coreclr/vm/genanalysis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bool gcGenAnalysisDump = false;
7676

7777
/* static */ void GenAnalysis::EnableGenerationalAwareSession()
7878
{
79+
#ifdef FEATURE_EVENT_TRACE
7980
WCHAR outputPath[MAX_PATH];
8081
ReplacePid(GENAWARE_TRACE_FILE_NAME, outputPath, MAX_PATH);
8182

@@ -115,4 +116,7 @@ bool gcGenAnalysisDump = false;
115116
{
116117
gcGenAnalysisTrace = false;
117118
}
119+
#else
120+
gcGenAnalysisTrace = false;
121+
#endif //FEATURE_EVENT_TRACE
118122
}

0 commit comments

Comments
 (0)