From 61a02edb7fb443b92f0682a00c42200def2bd33a Mon Sep 17 00:00:00 2001 From: Koundinya Veluri Date: Thu, 23 May 2019 10:49:10 -0700 Subject: Add some perf events/data for tiered compilation (#24607) Add some perf events/data for tiered compilation New events: - `Settings` - Sent when TC is enabled - `Flags` - Currently indicates whether QuickJit and QuickJitForLoops are enabled - `Pause` - Sent when TC is paused (due to a new method being called for the first time) - `Resume` - Sent when TC resumes - `NewMethodCount` - Number of methods called for the first time while tiering was paused - `BackgroundJitStart` - Sent when starting to JIT methods in the background - `PendingMethodCount` - Number of methods currently scheduled for background JIT - `BackgroundJitStop` - Sent when background jitting stops - `PendingMethodCount` - Same as above. When 0, background jitting has completed. - `JittedMethodCount` - Number of methods jitted in the background since the previous BackgroundJitStart event on the same thread Miscellaneous: - Updated method JIT events to include the optimization tier - Added a couple more cases where tiered compilation is disabled for methods that have JIT optimization disabled for some reason - Renamed `Duration` field of the new version of the `ContentionEnd` to `DurationNs` to indicate the units of time - Added `OptimizationTierOptimized` to `NativeCodeVersion::OptimizationTier` to distinguish it from `OptimizationTier1`. `OptimizationTierOptimized` is now used for methods that QuickJit is disabled for, and does not send the tier 1 flag. - For info about the code being generated by the JIT, added info to `PrepareCodeConfig` and stored a pointer to it on the thread object for the current JIT invocation. Info is updated in `PrepareCodeConfig` and used for updating the tier on the code version and for sending the ETL event. - If the JIT decides to use MinOpt when `MethodDesc::IsJitOptimizationDisabled()` is false, the info is not stored. The runtime method event will reflect the JIT's choice, the rundown event will not. - Updated to show optimization tiers in SOS similarly to PerfView --- src/vm/method.hpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/vm/method.hpp') diff --git a/src/vm/method.hpp b/src/vm/method.hpp index 66aacb94d2..09f57cd6f4 100644 --- a/src/vm/method.hpp +++ b/src/vm/method.hpp @@ -1253,6 +1253,8 @@ public: // can optimize its performance? Eligibility is invariant for the lifetime of a method. bool DetermineAndSetIsEligibleForTieredCompilation(); + bool IsJitOptimizationDisabled(); + private: // This function is not intended to be called in most places, and is named as such to discourage calling it accidentally bool Helper_IsEligibleForVersioningWithVtableSlotBackpatch() @@ -2065,6 +2067,56 @@ public: BOOL ReadyToRunRejectedPrecompiledCode(); void SetProfilerRejectedPrecompiledCode(); void SetReadyToRunRejectedPrecompiledCode(); + +#ifndef CROSSGEN_COMPILE + bool JitSwitchedToMinOpt() const + { + LIMITED_METHOD_CONTRACT; + return m_jitSwitchedToMinOpt; + } + + void SetJitSwitchedToMinOpt() + { + LIMITED_METHOD_CONTRACT; + +#ifdef FEATURE_TIERED_COMPILATION + m_jitSwitchedToOptimized = false; +#endif + m_jitSwitchedToMinOpt = true; + } + +#ifdef FEATURE_TIERED_COMPILATION + bool JitSwitchedToOptimized() const + { + LIMITED_METHOD_CONTRACT; + return m_jitSwitchedToOptimized; + } + + void SetJitSwitchedToOptimized() + { + LIMITED_METHOD_CONTRACT; + + if (!m_jitSwitchedToMinOpt) + { + m_jitSwitchedToOptimized = true; + } + } +#endif + + PrepareCodeConfig *GetNextInSameThread() const + { + LIMITED_METHOD_CONTRACT; + return m_nextInSameThread; + } + + void SetNextInSameThread(PrepareCodeConfig *config) + { + LIMITED_METHOD_CONTRACT; + _ASSERTE(config == nullptr || m_nextInSameThread == nullptr); + + m_nextInSameThread = config; + } +#endif // !CROSSGEN_COMPILE protected: MethodDesc* m_pMethodDesc; @@ -2073,6 +2125,15 @@ protected: BOOL m_mayUsePrecompiledCode; BOOL m_ProfilerRejectedPrecompiledCode; BOOL m_ReadyToRunRejectedPrecompiledCode; + +#ifndef CROSSGEN_COMPILE +private: + bool m_jitSwitchedToMinOpt; // when it wasn't requested +#ifdef FEATURE_TIERED_COMPILATION + bool m_jitSwitchedToOptimized; // when a different tier was requested +#endif + PrepareCodeConfig *m_nextInSameThread; +#endif // !CROSSGEN_COMPILE }; #ifdef FEATURE_CODE_VERSIONING -- cgit v1.2.3