More efficient executable allocator (#83632)
authorDavid Wrighton <davidwr@microsoft.com>
Thu, 13 Apr 2023 13:43:40 +0000 (06:43 -0700)
committerGitHub <noreply@github.com>
Thu, 13 Apr 2023 13:43:40 +0000 (15:43 +0200)
commit11a0671c0b8d30740e5f507a077bed87c905acd0
treeb94679401d12aabec7c37e6453dcfa3b70d37906
parente73d7fcb3ee12ae99bed53ed93e36091a067e341
More efficient executable allocator (#83632)

* Add multi-element caching scheme to ExecutableAllocator

* CodePageGenerator generated code for LoaderHeaps should not cache the RW mapping created, as it is never accessed again, and caching it is evicting useful data from the cache

* Fix build breaks introduced by executable mapping cache changes

* Fix build breaks caused by changes to introduce the concept of executable pages that aren't cached ever

* Move VSD executable heaps from being LoaderHeaps to being CodeFragmentHeaps
- Should reduce the amount of contention on the ExecutableAllocator cache
- Will improve the performance of identifying what type of stub is in use by avoiding the RangeList structure
  - Note, this will only apply to stubs which are used in somewhat larger applications

* Add statistics gathering features to ExecutableAllocator

* In progress

* Fix Dac api failing when called early in process startup

* Implement interleaved stubs as 16KB pages instead of 4KB pages

* Remove api incorrectly added

* Adjust cache size down to 3, and leave a breadcrumb for enabling more cache size exploration

* Fix x86 build

* Tweaks to make it all build and fix some bugs
- Notably, arm32 is now only using 4K pages as before, as it can't generate the proper immediate as needed.

* Add statistics for linked list walk lengths

* Reorder linked list on access

* Fix some more asserts and build breaks

* Fix Arm build for real this time, and fix unix arm64 miscalculation of which stubs to use

* Update based on code review comments

* More code review feedback

* Fix oops

* Attempt to fix Unix Arm64 build

* Try tweaking the number of cached mappings to see if the illegal instruction signal will go away in our testing

* Revert "Try tweaking the number of cached mappings to see if the illegal instruction signal will go away in our testing"

This reverts commit 983846083fea60eab9df53cf07a2fb5230c6c818.

* Fix last code review comment
42 files changed:
src/coreclr/debug/daccess/dacdbiimpl.cpp
src/coreclr/debug/daccess/fntableaccess.h
src/coreclr/debug/daccess/request.cpp
src/coreclr/inc/executableallocator.h
src/coreclr/inc/holder.h
src/coreclr/inc/loaderheap.h
src/coreclr/utilcode/executableallocator.cpp
src/coreclr/utilcode/loaderheap.cpp
src/coreclr/vm/amd64/excepamd64.cpp
src/coreclr/vm/amd64/thunktemplates.S
src/coreclr/vm/amd64/thunktemplates.asm
src/coreclr/vm/amd64/virtualcallstubcpu.hpp
src/coreclr/vm/appdomain.hpp
src/coreclr/vm/arm/exceparm.cpp
src/coreclr/vm/arm/virtualcallstubcpu.hpp
src/coreclr/vm/arm64/stubs.cpp
src/coreclr/vm/arm64/thunktemplates.S
src/coreclr/vm/arm64/thunktemplates.asm
src/coreclr/vm/arm64/virtualcallstubcpu.hpp
src/coreclr/vm/callcounting.cpp
src/coreclr/vm/callcounting.h
src/coreclr/vm/codeman.cpp
src/coreclr/vm/codeman.h
src/coreclr/vm/excep.cpp
src/coreclr/vm/gccover.cpp
src/coreclr/vm/i386/excepx86.cpp
src/coreclr/vm/i386/thunktemplates.S
src/coreclr/vm/i386/thunktemplates.asm
src/coreclr/vm/i386/virtualcallstubcpu.hpp
src/coreclr/vm/jitinterface.cpp
src/coreclr/vm/loaderallocator.cpp
src/coreclr/vm/loongarch64/stubs.cpp
src/coreclr/vm/loongarch64/thunktemplates.S
src/coreclr/vm/loongarch64/virtualcallstubcpu.hpp
src/coreclr/vm/precode.cpp
src/coreclr/vm/precode.h
src/coreclr/vm/prestub.cpp
src/coreclr/vm/stubmgr.cpp
src/coreclr/vm/util.cpp
src/coreclr/vm/util.hpp
src/coreclr/vm/virtualcallstub.cpp
src/coreclr/vm/virtualcallstub.h