diff options
author | David Wrighton <davidwr@microsoft.com> | 2019-04-25 10:57:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 10:57:09 -0700 |
commit | 713091f4e504b9a194dcb2cfda180baa21572c58 (patch) | |
tree | ec53ab52a5747f018ce7b9832aa4b212fe72d976 /src/vm/threads.cpp | |
parent | e3d7d212a4d5350227c1fcc6949e9a379e9162c5 (diff) | |
download | coreclr-713091f4e504b9a194dcb2cfda180baa21572c58.tar.gz coreclr-713091f4e504b9a194dcb2cfda180baa21572c58.tar.bz2 coreclr-713091f4e504b9a194dcb2cfda180baa21572c58.zip |
Improve the performance of the type loader (#24177)
Improve the performance of the type loader
- Disable interface ambiguity checks in Corelib
- Improve StackingAllocator perf
- Increase size of allocation blocks
- Cleanup allocation blocks comletely on gc suspension
- Check for presence of generic parameters to methods in a more efficient manner
- Querying the count of GenericParameter records requires a binary search in the GenericParams table
- Checking the generic flag on the method signature is effectively free
- Skip unnecessary checks in EnumerateClassMethods for corelib
- Use Sanity check flag where appropriate
- Use slightly faster hashtable functions in StringLiteralMap
- Remove pointless string literal entry hash table search
- Change stacking allocator to not be allocated for the lifetime of a thread, but instead its allocated/destroyed around the first frame on the thread that needs the allocator.
- Allocate at most 1 stacking allocator per thread
- The allocation is on the stack via _alloca (as managed by the ACQUIRE_STACKING_ALLOCATOR macro
- This will put an 8KB buffer on the stack, and if there is need for a larger buffer it will allocate off of the heap.
- Stacking allocator initial block is always present, so the allocation routine for the allocator can be somewhat simpler
- More logic has been move the the cpp file, to reduce header bloat, and improve iteration when modifying StackingAllocator code
- Avoid use of alloca for StackingAllocator when less than 512KB of stack is available
Diffstat (limited to 'src/vm/threads.cpp')
-rw-r--r-- | src/vm/threads.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp index 37d30c392a..73d452c0e4 100644 --- a/src/vm/threads.cpp +++ b/src/vm/threads.cpp @@ -1402,6 +1402,7 @@ Thread::Thread() m_CacheStackBase = 0; m_CacheStackLimit = 0; m_CacheStackSufficientExecutionLimit = 0; + m_CacheStackStackAllocNonRiskyExecutionLimit = 0; m_LastAllowableStackAddress= 0; m_ProbeLimit = 0; @@ -6445,6 +6446,20 @@ BOOL Thread::SetStackLimits(SetStackLimitScope scope) { m_CacheStackSufficientExecutionLimit = reinterpret_cast<UINT_PTR>(m_CacheStackBase); } + + // Compute the limit used by CheckCanUseStackAllocand cache it on the thread. This minimum stack size should + // be sufficient to avoid all significant risk of a moderate size stack alloc interfering with application behavior + const UINT_PTR StackAllocNonRiskyExecutionStackSize = 512 * 1024; + _ASSERTE(m_CacheStackBase >= m_CacheStackLimit); + if ((reinterpret_cast<UINT_PTR>(m_CacheStackBase) - reinterpret_cast<UINT_PTR>(m_CacheStackLimit)) > + StackAllocNonRiskyExecutionStackSize) + { + m_CacheStackStackAllocNonRiskyExecutionLimit = reinterpret_cast<UINT_PTR>(m_CacheStackLimit) + StackAllocNonRiskyExecutionStackSize; + } + else + { + m_CacheStackStackAllocNonRiskyExecutionLimit = reinterpret_cast<UINT_PTR>(m_CacheStackBase); + } } // Ensure that we've setup the stack guarantee properly before we cache the stack limits @@ -8156,8 +8171,6 @@ void Thread::InternalReset(BOOL fNotFinalizerThread, BOOL fThreadObjectResetNeed nPriority = ResetManagedThreadObject(nPriority); } - //m_MarshalAlloc.Collapse(NULL); - if (fResetAbort && IsAbortRequested()) { UnmarkThreadForAbort(TAR_ALL); } |