Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
40d9308
Proof of concept synchronous profiler EventPipe events
davmason May 24, 2020
7e2bbd8
Add provider callback and ability to query provider name
davmason May 25, 2020
a6ecda8
add guids to API
davmason May 26, 2020
af29c79
stop creating a buffer manager for synchronous sessions
davmason May 26, 2020
7198ac5
Take lock before adding provider to session
davmason May 26, 2020
7f3642c
fix linux build error
davmason May 26, 2020
1eb39d7
refactoring
davmason May 28, 2020
ce70d00
Get rid of enablecpusampling argument
davmason Jun 19, 2020
d644cba
move EventPipeProviderCreated profiler callback outside of lock
davmason Jun 19, 2020
8d1b5bc
refactor SuspendWriteEvent so it covers the synchronous callback case…
davmason Jun 20, 2020
7cb9a1a
after EventPipe starts shutting down return an error for EventPipeSta…
davmason Jun 21, 2020
c132d07
switch to spinlock since we can't use crst in gc_notrigger/coop
davmason Jun 22, 2020
ee9aee8
Add assert and remove unused variable
davmason Jun 23, 2020
540d8e3
Move storing null to the session array before EventPipeSession::Suspe…
davmason Jun 23, 2020
5eca5ef
remove spurious assert
davmason Jun 23, 2020
619f4b8
Fix SampleProfiler refcount issue, double profiler callback, remove u…
davmason Jun 24, 2020
7905bcf
remove the concept of m_writeEventSuspending from the buffer manager …
davmason Jun 24, 2020
96d8cc4
Add test
davmason May 26, 2020
87ceca4
add description of filter data format
davmason Jun 25, 2020
0cc9a28
fix x86 test build issues
davmason Jun 25, 2020
008dabd
exlcude test from mono
davmason Jun 26, 2020
68e3479
move waiting on threads to finish writing outside of the lock
davmason Jun 26, 2020
2c3429e
allow call to GetProviderInfo to get the length of the name
davmason Jun 27, 2020
5ab6fd0
Fix formatting
davmason Jun 27, 2020
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
stop creating a buffer manager for synchronous sessions
  • Loading branch information
davmason committed Jun 25, 2020
commit af29c79afc866e04807f017ced5c038b8039d14a
2 changes: 1 addition & 1 deletion src/coreclr/src/vm/eventpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ EventPipeSessionID EventPipe::Enable(
GC_TRIGGERS;
MODE_PREEMPTIVE;
PRECONDITION(format < EventPipeSerializationFormat::Count);
PRECONDITION(circularBufferSizeInMB > 0);
PRECONDITION(sessionType == EventPipeSessionType::Synchronous || circularBufferSizeInMB > 0);
PRECONDITION(numProviders > 0 && pProviders != nullptr);
}
CONTRACTL_END;
Expand Down
36 changes: 30 additions & 6 deletions src/coreclr/src/vm/eventpipesession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ EventPipeSession::EventPipeSession(
m_SessionType(sessionType),
m_format(format),
m_rundownRequested(rundownSwitch),
m_synchronousCallback(callback)
m_synchronousCallback(callback),
m_pBufferManager(nullptr)
{
CONTRACTL
{
Expand All @@ -39,7 +40,7 @@ EventPipeSession::EventPipeSession(
MODE_PREEMPTIVE;
PRECONDITION(index < EventPipe::MaxNumberOfSessions);
PRECONDITION(format < EventPipeSerializationFormat::Count);
PRECONDITION(circularBufferSizeInMB > 0);
PRECONDITION(m_SessionType == EventPipeSessionType::Synchronous || circularBufferSizeInMB > 0);
PRECONDITION(numProviders > 0 && pProviders != nullptr);
PRECONDITION(EventPipe::IsLockOwnedByCurrentThread());
PRECONDITION((m_synchronousCallback != nullptr) == (m_SessionType == EventPipeSessionType::Synchronous));
Expand All @@ -55,7 +56,10 @@ EventPipeSession::EventPipeSession(
sequencePointAllocationBudget = 10 * 1024 * 1024;
}

m_pBufferManager = new EventPipeBufferManager(this, static_cast<size_t>(circularBufferSizeInMB) << 20, sequencePointAllocationBudget);
if (m_SessionType != EventPipeSessionType::Synchronous)
{
m_pBufferManager = new EventPipeBufferManager(this, static_cast<size_t>(circularBufferSizeInMB) << 20, sequencePointAllocationBudget);
}

// Create the event pipe file.
// A NULL output path means that we should not write the results to a file.
Expand Down Expand Up @@ -93,7 +97,10 @@ EventPipeSession::~EventPipeSession()
CONTRACTL_END;

delete m_pProviderList;
delete m_pBufferManager;
if (m_pBufferManager != nullptr)
{
delete m_pBufferManager;
}
delete m_pFile;
}

Expand Down Expand Up @@ -297,7 +304,7 @@ bool EventPipeSession::WriteAllBuffersToFile(bool *pEventsWritten)
}
CONTRACTL_END;

if (m_pFile == nullptr)
if (m_pFile == nullptr || m_pBufferManager == nullptr)
return true;

// Get the current time stamp.
Expand Down Expand Up @@ -347,6 +354,7 @@ bool EventPipeSession::WriteEvent(
}
else
{
_ASSERTE(m_pBufferManager != nullptr);
return m_pBufferManager->WriteEvent(pThread, *this, event, payload, pActivityId, pRelatedActivityId, pEventThread, pStack);
}
}
Expand All @@ -364,7 +372,7 @@ void EventPipeSession::WriteSequencePointUnbuffered()
}
CONTRACTL_END;

if (m_pFile == nullptr)
if (m_pFile == nullptr || m_pBufferManager == nullptr)
return;
EventPipeSequencePoint sequencePoint;
m_pBufferManager->InitSequencePointThreadList(&sequencePoint);
Expand All @@ -382,13 +390,23 @@ EventPipeEventInstance *EventPipeSession::GetNextEvent()
}
CONTRACTL_END;

if (m_pBufferManager == nullptr)
{
return nullptr;
}

return m_pBufferManager->GetNextEvent();
}

CLREvent *EventPipeSession::GetWaitEvent()
{
LIMITED_METHOD_CONTRACT;

if (m_pBufferManager == nullptr)
{
return nullptr;
}

return m_pBufferManager->GetWaitEvent();
}

Expand Down Expand Up @@ -476,6 +494,7 @@ void EventPipeSession::DisableIpcStreamingThread()
CONTRACTL_END;

_ASSERTE(!g_fProcessDetach);
_ASSERTE(m_pBufferManager != nullptr);

// The IPC streaming thread will watch this value and exit
// when profiling is disabled.
Expand Down Expand Up @@ -517,6 +536,11 @@ void EventPipeSession::SuspendWriteEvent()
}
CONTRACTL_END;

if (m_pBufferManager == nullptr)
{
return;
}

// Force all in-progress writes to either finish or cancel
// This is required to ensure we can safely flush and delete the buffers
m_pBufferManager->SuspendWriteEvent(GetIndex());
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7103,7 +7103,7 @@ HRESULT ProfToEEInterfaceImpl::EventPipeStartSession(

EventPipeProviderConfiguration *pProviders = reinterpret_cast<EventPipeProviderConfiguration *>(pProviderConfigs);
UINT64 sessionID = EventPipe::Enable(NULL,
100, // circularBufferSizeInMB (shouldn't need this once it's synchronous)
0, // We don't use a circular buffer since it's synchronous
pProviders,
cProviderConfigs,
EventPipeSessionType::Synchronous,
Expand Down