Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Code review feedback
  • Loading branch information
cshung committed Aug 14, 2020
commit d659800c29185243fb984b7072234568814e329b
63 changes: 34 additions & 29 deletions src/coreclr/src/vm/eventpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,35 +265,40 @@ void EventPipe::EnableViaEnvironmentVariables()
if (gcGenAnalysisConfigured == 1 && gcGenAnalysisState == 0)
#endif
{
LPCWSTR outputPath = nullptr;
outputPath = W("gcgenaware.nettrace");
NewHolder<EventPipeProviderConfiguration> pProviders = nullptr;
int providerCnt = 1;
pProviders = new EventPipeProviderConfiguration[providerCnt];
const uint64_t GenAwareKeyword = 0x10000000000; // This keyword is necessary for the start and stop events
const uint64_t GCHeapAndTypeNamesKeyword = 0x00001000000; // This keyword is necessary for the type names
const uint64_t GCHeapSurvivalAndMovementKeyword = 0x00000400000; // This keyword is necessary for the generation range data.
const uint64_t GCHeapDumpKeyword = 0x00000100000; // This keyword is necessary for enabling walking the heap
const uint64_t TypeKeyword = 0x00000080000; // This keyword is necessary for enabling BulkType events
const uint64_t keyword = GenAwareKeyword|GCHeapAndTypeNamesKeyword|GCHeapSurvivalAndMovementKeyword|GCHeapDumpKeyword|TypeKeyword;
pProviders[0] = EventPipeProviderConfiguration(W("Microsoft-Windows-DotNETRuntime"), keyword, 5, nullptr);
gcGenAnalysisEventPipeSessionId = EventPipe::Enable(
outputPath,
1024,
pProviders,
providerCnt,
EventPipeSessionType::File,
EventPipeSerializationFormat::NetTraceV4,
false,
nullptr
);
if (gcGenAnalysisEventPipeSessionId > 0)
{
gcGenAnalysisEventPipeSession= EventPipe::GetSession(gcGenAnalysisEventPipeSessionId);
gcGenAnalysisEventPipeSession->Pause();
EventPipe::StartStreaming(gcGenAnalysisEventPipeSessionId);
gcGenAnalysisState = GcGenAnalysisState::Enabled;
}
EnableGenerationalAwareSession();
}
}

void EventPipe::EnableGenerationalAwareSession()
{
LPCWSTR outputPath = nullptr;
outputPath = W("gcgenaware.nettrace");
NewHolder<EventPipeProviderConfiguration> pProviders = nullptr;
int providerCnt = 1;
pProviders = new EventPipeProviderConfiguration[providerCnt];
const uint64_t GenAwareKeyword = 0x10000000000; // This keyword is necessary for the start and stop events
const uint64_t GCHeapAndTypeNamesKeyword = 0x00001000000; // This keyword is necessary for the type names
const uint64_t GCHeapSurvivalAndMovementKeyword = 0x00000400000; // This keyword is necessary for the generation range data.
const uint64_t GCHeapDumpKeyword = 0x00000100000; // This keyword is necessary for enabling walking the heap
const uint64_t TypeKeyword = 0x00000080000; // This keyword is necessary for enabling BulkType events
const uint64_t keyword = GenAwareKeyword|GCHeapAndTypeNamesKeyword|GCHeapSurvivalAndMovementKeyword|GCHeapDumpKeyword|TypeKeyword;
pProviders[0] = EventPipeProviderConfiguration(W("Microsoft-Windows-DotNETRuntime"), keyword, 5, nullptr);
gcGenAnalysisEventPipeSessionId = EventPipe::Enable(
outputPath,
1024,
pProviders,
providerCnt,
EventPipeSessionType::File,
EventPipeSerializationFormat::NetTraceV4,
false,
nullptr
);
if (gcGenAnalysisEventPipeSessionId > 0)
{
gcGenAnalysisEventPipeSession= EventPipe::GetSession(gcGenAnalysisEventPipeSessionId);
gcGenAnalysisEventPipeSession->Pause();
EventPipe::StartStreaming(gcGenAnalysisEventPipeSessionId);
gcGenAnalysisState = GcGenAnalysisState::Enabled;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/src/vm/eventpipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class EventPipe
// Initialize environment variable based session
static void EnableViaEnvironmentVariables();

// Initialize generation aware analysis sesssion
static void EnableGenerationalAwareSession();

// Shutdown the event pipe.
static void Shutdown();

Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/src/vm/eventpipesession.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ class EventPipeSession

void DisableIpcStreamingThread();

// Note - access to this field is NOT synchronized
//
// This field is currently modified in EventPipe::EnableViaEnvironmentVariables() during process startup
// and GCToEEInterface::AnalyzeSurvivorsFinished() while the GC has already synchronized all the threads.
//
// It is read in EventPipeSession::WriteEvent(). While it is possible for other preemptive threads to read
// the field while GC is happening, it should not happen because the only gcGenAwareSession only subscribe
// to GC events.
bool m_paused;

public:
Expand Down
35 changes: 1 addition & 34 deletions src/coreclr/src/vm/finalizerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,40 +274,7 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
fclose(fopen("trace.nettrace.completed","w+"));
#ifdef GEN_ANALYSIS_STRESS
{
LPCWSTR outputPath = nullptr;
outputPath = W("gcgenaware.nettrace");
NewHolder<EventPipeProviderConfiguration> pProviders = nullptr;
int providerCnt = 1;
pProviders = new EventPipeProviderConfiguration[providerCnt];
const uint64_t GenAwareKeyword = 0x10000000000; // This keyword is necessary for the start and stop events
const uint64_t GCHeapAndTypeNamesKeyword = 0x00001000000; // This keyword is necessary for the type names
const uint64_t GCHeapSurvivalAndMovementKeyword = 0x00000400000; // This keyword is necessary for the generation range data.
const uint64_t GCHeapDumpKeyword = 0x00000100000; // This keyword is necessary for enabling walking the heap
const uint64_t TypeKeyword = 0x00000080000; // This keyword is necessary for enabling BulkType events
const uint64_t keyword = GenAwareKeyword|GCHeapAndTypeNamesKeyword|GCHeapSurvivalAndMovementKeyword|GCHeapDumpKeyword|TypeKeyword;
pProviders[0] = EventPipeProviderConfiguration(W("Microsoft-Windows-DotNETRuntime"), keyword, 5, nullptr);
gcGenAnalysisEventPipeSessionId = EventPipe::Enable(
outputPath,
1024,
pProviders,
providerCnt,
EventPipeSessionType::File,
EventPipeSerializationFormat::NetTraceV4,
false,
nullptr
);
if (gcGenAnalysisEventPipeSessionId > 0)
{
gcGenAnalysisEventPipeSession= EventPipe::GetSession(gcGenAnalysisEventPipeSessionId);
// gcGenAnalysisEventPipeSession == nullptr is possible if EventPipe::Shutdown() is called
// right after the Enable() call completes above and before EventPipe::GetSession() is called.
if (gcGenAnalysisEventPipeSession != nullptr)
{
gcGenAnalysisEventPipeSession->Pause();
EventPipe::StartStreaming(gcGenAnalysisEventPipeSessionId);
gcGenAnalysisState = GcGenAnalysisState::Enabled;
}
}
EventPipe::EnableGenerationalAwareSession();
}
#endif
}
Expand Down