summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Robbins <brianrob@microsoft.com>2018-11-29 16:39:41 -0800
committerGitHub <noreply@github.com>2018-11-29 16:39:41 -0800
commitb6c346828eb393d93dd6204a1e88a651e68cdb3e (patch)
tree13c887917dcaa5fe76cc4a4606a740c7d38f4b9a
parent85b11e6dcc0e08c7e9733ee33360f1bee2acb6dd (diff)
downloadcoreclr-b6c346828eb393d93dd6204a1e88a651e68cdb3e.tar.gz
coreclr-b6c346828eb393d93dd6204a1e88a651e68cdb3e.tar.bz2
coreclr-b6c346828eb393d93dd6204a1e88a651e68cdb3e.zip
Defer Initialization of FrameworkEventSource During EventPipeController Initialization (#21255)
-rw-r--r--src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeController.cs14
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Timer.cs3
2 files changed, 16 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeController.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeController.cs
index ef5f331e25..7e7fec72b5 100644
--- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeController.cs
+++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeController.cs
@@ -60,6 +60,9 @@ namespace System.Diagnostics.Tracing
// Singleton controller instance.
private static EventPipeController s_controllerInstance = null;
+ // Initialization flag used to avoid initializing FrameworkEventSource on the startup path.
+ private static bool s_initializing = false;
+
// Controller object state.
private Timer m_timer;
private string m_configFilePath;
@@ -67,11 +70,18 @@ namespace System.Diagnostics.Tracing
private string m_traceFilePath = null;
private bool m_configFileExists = false;
+ internal static bool Initializing
+ {
+ get { return s_initializing; }
+ }
+
internal static void Initialize()
{
// Don't allow failures to propagate upstream. Ensure program correctness without tracing.
try
{
+ s_initializing = true;
+
if (s_controllerInstance == null)
{
if (Config_EnableEventPipe > 0)
@@ -88,6 +98,10 @@ namespace System.Diagnostics.Tracing
}
}
catch { }
+ finally
+ {
+ s_initializing = false;
+ }
}
private EventPipeController()
diff --git a/src/System.Private.CoreLib/src/System/Threading/Timer.cs b/src/System.Private.CoreLib/src/System/Threading/Timer.cs
index 0bc235db6e..eeacf5b8c5 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Timer.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Timer.cs
@@ -567,7 +567,8 @@ namespace System.Threading
}
else
{
- if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.ThreadTransfer))
+ // Don't emit this event during EventPipeController. This avoids initializing FrameworkEventSource during start-up which is expensive relative to the rest of start-up.
+ if (!EventPipeController.Initializing && FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.ThreadTransfer))
FrameworkEventSource.Log.ThreadTransferSendObj(this, 1, string.Empty, true, (int)dueTime, (int)period);
success = m_associatedTimerQueue.UpdateTimer(this, dueTime, period);