Skip to content
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
1 change: 0 additions & 1 deletion src/coreclr/clr.featuredefines.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>
<PropertyGroup>
<FeatureCoreCLR>true</FeatureCoreCLR>
<FeatureEventTrace>true</FeatureEventTrace>
<FeaturePerfTracing>true</FeaturePerfTracing>
<ProfilingSupportedBuild>true</ProfilingSupportedBuild>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
endif()

if(NOT DEFINED FEATURE_EVENT_TRACE)
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
set(FEATURE_EVENT_TRACE 1)
endif(NOT DEFINED FEATURE_EVENT_TRACE)

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/dlls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if(CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
add_subdirectory(clretwrc)
endif(CLR_CMAKE_TARGET_WIN32)
endif(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
if (NOT (CLR_CMAKE_TARGET_WIN32 AND FEATURE_CROSSBITNESS))
add_subdirectory(mscordbi)
add_subdirectory(mscordac)
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26100,6 +26100,7 @@ void gc_heap::calculate_new_heap_count ()
mb (total_soh_stable_size), mb (total_bcd), diff_pct, change_int, (change_int * 100.0 / n_heaps)));
}

#ifdef FEATURE_EVENT_TRACE
GCEventFireSizeAdaptationTuning_V1 (
(uint16_t)new_n_heaps,
(uint16_t)max_heap_count_datas,
Expand All @@ -26118,6 +26119,7 @@ void gc_heap::calculate_new_heap_count ()
(uint16_t)hc_change_freq_factor,
(uint16_t)hc_freq_reason,
(uint8_t)adj_metric);
#endif //FEATURE_EVENT_TRACE
}

size_t num_gen2s_since_last_change = 0;
Expand Down Expand Up @@ -26173,6 +26175,7 @@ void gc_heap::calculate_new_heap_count ()
if (process_gen2_samples_p)
{
dynamic_heap_count_data_t::gen2_sample* gen2_samples = dynamic_heap_count_data.gen2_samples;
#ifdef FEATURE_EVENT_TRACE
GCEventFireSizeAdaptationFullGCTuning_V1 (
(uint16_t)dynamic_heap_count_data.new_n_heaps,
(uint64_t)current_gc_index,
Expand All @@ -26184,6 +26187,7 @@ void gc_heap::calculate_new_heap_count ()
(float)gen2_samples[1].gc_percent,
(uint32_t)(current_gc_index - gen2_samples[2].gc_index),
(float)gen2_samples[2].gc_percent);
#endif //FEATURE_EVENT_TRACEs

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));
dynamic_heap_count_data.processed_gen2_samples_count = dynamic_heap_count_data.current_gen2_samples_count;
Expand Down Expand Up @@ -26879,12 +26883,14 @@ void gc_heap::process_datas_sample()
(sample.gc_pause_time ? (sample.gc_survived_size / 1000.0 / sample.gc_pause_time) : 0),
(sample.gc_pause_time ? ((float)sample.gc_survived_size / sample.gc_pause_time / n_heaps) : 0)));

#ifdef FEATURE_EVENT_TRACE
GCEventFireSizeAdaptationSample_V1 (
(uint64_t)gc_index,
(uint32_t)sample.elapsed_between_gcs,
(uint32_t)sample.gc_pause_time,
(uint32_t)soh_msl_wait_time, (uint32_t)uoh_msl_wait_time,
(uint64_t)total_soh_stable_size, (uint32_t)sample.gen0_budget_per_heap);
#endif //FEATURE_EVENT_TRACE

dynamic_heap_count_data.sample_index = (dynamic_heap_count_data.sample_index + 1) % dynamic_heap_count_data_t::sample_size;
(dynamic_heap_count_data.current_samples_count)++;
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/inc/profilepriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#ifndef _ProfilePriv_h_
#define _ProfilePriv_h_

#ifndef FEATURE_PERFTRACING
typedef struct _EventPipeProvider EventPipeProvider;
#endif //FEATURE_PERFTRACING

// Forward declarations
class EEToProfInterfaceImpl;
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/vm/finalizerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
gcGenAnalysisState = GcGenAnalysisState::Disabled;
if (gcGenAnalysisTrace)
{
#ifdef FEATURE_PERFTRACING
EventPipeAdapter::Disable(gcGenAnalysisEventPipeSessionId);
#ifdef GEN_ANALYSIS_STRESS
GenAnalysis::EnableGenerationalAwareSession();
#endif
#endif //GEN_ANALYSIS_STRESS
#endif //FEATURE_PERFTRACING
}

// Writing an empty file to indicate completion
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
{
if (gcGenAnalysisTrace)
{
#ifdef FEATURE_PERFTRACING
EventPipeAdapter::ResumeSession(gcGenAnalysisEventPipeSession);
FireEtwGenAwareBegin((int)gcIndex, GetClrInstanceId());
s_forcedGCInProgress = true;
Expand All @@ -1732,6 +1733,7 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
reportGenerationBounds();
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
#endif //FEATURE_PERFTRACING
}
if (gcGenAnalysisDump)
{
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/gchelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ inline void CheckObjectSize(size_t alloc_size)

void FireAllocationSampled(GC_ALLOC_FLAGS flags, size_t size, size_t samplingBudgetOffset, Object* orObject)
{
#ifdef FEATURE_EVENT_TRACE
// Note: this code is duplicated from GCToCLREventSink::FireGCAllocationTick_V4
void* typeId = nullptr;
const WCHAR* name = nullptr;
Expand Down Expand Up @@ -212,6 +213,7 @@ void FireAllocationSampled(GC_ALLOC_FLAGS flags, size_t size, size_t samplingBud
0; // SOH
FireEtwAllocationSampled(allocKind, GetClrInstanceId(), typeId, name, (BYTE*)orObject, size, samplingBudgetOffset);
}
#endif //FEATURE_EVENT_TRACE
}

inline Object* Alloc(ee_alloc_context* pEEAllocContext, size_t size, GC_ALLOC_FLAGS flags)
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/genanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ bool gcGenAnalysisDump = false;

/* static */ void GenAnalysis::EnableGenerationalAwareSession()
{
#ifdef FEATURE_EVENT_TRACE
WCHAR outputPath[MAX_PATH];
ReplacePid(GENAWARE_TRACE_FILE_NAME, outputPath, MAX_PATH);

Expand Down Expand Up @@ -115,4 +116,7 @@ bool gcGenAnalysisDump = false;
{
gcGenAnalysisTrace = false;
}
#else
gcGenAnalysisTrace = false;
#endif //FEATURE_EVENT_TRACE
}
2 changes: 2 additions & 0 deletions src/coreclr/vm/genanalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef FEATURE_PERFTRACING
#include "eventpipeadaptertypes.h"
#else
typedef struct _EventPipeSession EventPipeSession;
#endif // FEATURE_PERFTRACING

enum GcGenAnalysisState
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,21 +827,23 @@ PCODE MethodDesc::JitCompileCodeLockedEventWrapper(PrepareCodeConfig* pConfig, J
else
{
SString namespaceOrClassName, methodName, methodSignature;

#ifdef FEATURE_EVENT_TRACE
ETW::MethodLog::MethodJitting(this,
pilHeader,
&namespaceOrClassName,
&methodName,
&methodSignature);
#endif //FEATURE_EVENT_TRACE

pCode = JitCompileCodeLocked(pConfig, pilHeader, pEntry, &sizeOfCode);

#ifdef FEATURE_EVENT_TRACE
ETW::MethodLog::MethodJitted(this,
&namespaceOrClassName,
&methodName,
&methodSignature,
pCode,
pConfig);
#endif //FEATURE_EVENT_TRACE
}

#ifdef PROFILING_SUPPORTED
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/profilinghelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ void ProfilingAPIUtility::LogProfEventVA(

AppendSupplementaryInformation(iStringResourceID, &messageToLog);

#ifdef FEATURE_EVENT_TRACE
if (EventEnabledProfilerMessage())
{
StackSString messageToLogUtf16;
Expand All @@ -325,6 +326,7 @@ void ProfilingAPIUtility::LogProfEventVA(
// Write to ETW and EventPipe with the message
FireEtwProfilerMessage(GetClrInstanceId(), messageToLogUtf16.GetUnicode());
}
#endif //FEATURE_EVENT_TRACE

// Output debug strings for diagnostic messages.
OutputDebugStringUtf8(messageToLog.GetUTF8());
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/vm/yieldprocessornormalizedshared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ void YieldProcessorNormalization::PerformMeasurement()
}
if (i < NsPerYieldMeasurementCount - 1)
{
#ifdef FEATURE_EVENT_TRACE
FireEtwYieldProcessorMeasurement(GetClrInstanceId(), latestNsPerYield, s_establishedNsPerYield);
#endif //FEATURE_EVENT_TRACE
}
}
}
Expand All @@ -204,9 +206,9 @@ void YieldProcessorNormalization::PerformMeasurement()
{
AtomicStore(&s_establishedNsPerYield, establishedNsPerYield);
}

#ifdef FEATURE_EVENT_TRACE
FireEtwYieldProcessorMeasurement(GetClrInstanceId(), latestNsPerYield, s_establishedNsPerYield);

#endif //FEATURE_EVENT_TRACE
// Calculate the number of yields required to span the duration of a normalized yield
unsigned int yieldsPerNormalizedYield = max(1u, (unsigned int)(TargetNsPerNormalizedYield / establishedNsPerYield + 0.5));
_ASSERTE(yieldsPerNormalizedYield <= MaxYieldsPerNormalizedYield);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Diagnostics.Tracing
{
internal static partial class EventPipeInternal
{
#if FEATURE_PERFTRACING
//
// These PInvokes are used by the configuration APIs to interact with EventPipe.
//
Expand Down Expand Up @@ -64,5 +65,72 @@ internal static unsafe partial IntPtr CreateProvider(string providerName,
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "EventPipeInternal_WaitForSessionSignal")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static unsafe partial bool WaitForSessionSignal(ulong sessionID, int timeoutMs);
#else
#pragma warning disable IDE0060
private static unsafe ulong Enable(
char* outputFile,
EventPipeSerializationFormat format,
uint circularBufferSizeInMB,
EventPipeProviderConfigurationNative* providers,
uint numProviders)
{
return 0;
}

internal static void Disable(ulong sessionID)
{
}

internal static unsafe IntPtr CreateProvider(string providerName,
delegate* unmanaged<byte*, int, byte, long, long, Interop.Advapi32.EVENT_FILTER_DESCRIPTOR*, void*, void> callbackFunc,
void* callbackContext)
{
return IntPtr.Zero;
}

internal static unsafe IntPtr DefineEvent(IntPtr provHandle, uint eventID, long keywords, uint eventVersion, uint level, void *pMetadata, uint metadataLength)
{
return IntPtr.Zero;
}

internal static IntPtr GetProvider(string providerName)
{
return IntPtr.Zero;
}

internal static void DeleteProvider(IntPtr provHandle)
{
}

internal static int EventActivityIdControl(uint controlCode, ref Guid activityId)
{
return 0;
}

internal static unsafe void WriteEventData(IntPtr eventHandle, EventProvider.EventData* pEventData, uint dataCount, Guid* activityId, Guid* relatedActivityId)
{
}

internal static unsafe bool GetSessionInfo(ulong sessionID, EventPipeSessionInfo* pSessionInfo)
{
return false;
}

internal static unsafe bool GetNextEvent(ulong sessionID, EventPipeEventInstanceData* pInstance)
{
return false;
}

internal static unsafe bool SignalSession(ulong sessionID)
{
return false;
}

internal static unsafe bool WaitForSessionSignal(ulong sessionID, int timeoutMs)
{
return false;
}
#pragma warning restore IDE0060
#endif //FEATURE_PERFTRACING
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ internal sealed class EventPipeWaitHandle : WaitHandle

internal static partial class EventPipeInternal
{
#if FEATURE_PERFTRACING
private unsafe struct EventPipeProviderConfigurationNative
{
private char* m_pProviderName;
Expand Down Expand Up @@ -146,5 +147,21 @@ internal static unsafe ulong Enable(
}
}
}
#else
#pragma warning disable IDE0060
private unsafe struct EventPipeProviderConfigurationNative
{
}

internal static unsafe ulong Enable(
string? outputFile,
EventPipeSerializationFormat format,
uint circularBufferSizeInMB,
EventPipeProviderConfiguration[] providers)
{
return 0;
}
#pragma warning restore IDE0060
#endif //FEATURE_PERFTRACING
}
}
8 changes: 7 additions & 1 deletion src/native/corehost/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ else()
coreclrpal_dac
corguids
dbgutil
eventprovider
)
if (FEATURE_EVENT_TRACE)
LIST(APPEND NATIVE_LIBS
eventprovider
)
endif(FEATURE_EVENT_TRACE)
LIST(APPEND NATIVE_LIBS
nativeresourcestring
)

Expand Down
Loading