-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use preferred region from PAL for JIT reloc hints #60747
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1319,6 +1319,25 @@ PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange( | |||||||||||||||||||||||||||||||||||||
#endif // HOST_64BIT | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/*++ | ||||||||||||||||||||||||||||||||||||||
Function: | ||||||||||||||||||||||||||||||||||||||
PAL_GetExecutableMemoryAllocatorReservedRange | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
This function gets the reserved range allocated by the executable memory allocator. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
lpBeginAddress - Inclusive beginning of range | ||||||||||||||||||||||||||||||||||||||
lpEndAddress - Exclusive end of range | ||||||||||||||||||||||||||||||||||||||
dwSize - Number of bytes to allocate | ||||||||||||||||||||||||||||||||||||||
--*/ | ||||||||||||||||||||||||||||||||||||||
void | ||||||||||||||||||||||||||||||||||||||
PALAPI | ||||||||||||||||||||||||||||||||||||||
PAL_GetExecutableMemoryAllocatorReservedRange( | ||||||||||||||||||||||||||||||||||||||
OUT LPVOID *start, | ||||||||||||||||||||||||||||||||||||||
OUT LPVOID *end) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
g_executableMemoryAllocator.GetReservedRange(start, end); | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we combine it with the libcoreclr.so range (using real base and the guesstimate CoreClrLibrarySize as a size)? In case there was a space in between, we could pretend it is not there. I think that without it, calls to helpers in it would not be optimized, or would they? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We always assume we can do rip-relative calls and the runtime will generate jump stubs if necessary, so calls to helpers already work out well with the current scheme. The question is if we ever bake in static addresses in coreclr.dll as part of jitted code -- those could not be contained without what you suggest. I can try to make this change tomorrow or Monday and see if there are any additional diffs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That further helps, we sometime call helpers through indirections of static variables stored in coreclr.dll: runtime/src/coreclr/vm/jitinterface.cpp Lines 10610 to 10627 in c1d6d84
In particular CORINFO_HELP_STOP_FOR_GC is one that has quite a few hits. That furthermore is conditional based on a static variable, so each site changes like this:
G_M40601_IG08:
mov byte ptr [rbx+12], 1
- mov rdi, 0xD1FFAB1E
- cmp dword ptr [rdi], 0
+ cmp dword ptr [(reloc)], 0
je SHORT G_M40601_IG09
- mov rsi, 0xD1FFAB1E
- call [rsi]CORINFO_HELP_STOP_FOR_GC
- ;; bbWeight=0.50 PerfScore 4.25
+ call [CORINFO_HELP_STOP_FOR_GC]
+ ;; bbWeight=0.50 PerfScore 4.00 The additional diffs are: Summary of Code Size diffs:
(Lower is better)
Total bytes of base: 59803609
Total bytes of diff: 59772903
Total bytes of delta: -30706 (-0.05 % of base)
Total relative delta: NaN
diff is an improvement.
relative diff is a regression.
Top file improvements (bytes):
-7410 : System.Private.CoreLib.dasm (-0.13 % of base)
-4853 : System.Drawing.Common.dasm (-1.26 % of base)
-1946 : System.Security.Cryptography.Algorithms.dasm (-0.49 % of base)
-1170 : System.Security.Cryptography.X509Certificates.dasm (-0.32 % of base)
-1026 : System.Net.Security.dasm (-0.57 % of base)
-895 : System.Net.Sockets.dasm (-0.40 % of base)
-876 : System.Diagnostics.Process.dasm (-0.98 % of base)
-852 : System.DirectoryServices.Protocols.dasm (-0.72 % of base)
-772 : System.Security.Cryptography.OpenSsl.dasm (-0.69 % of base)
-713 : System.Console.dasm (-0.92 % of base)
-686 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (-0.02 % of base)
-618 : System.Private.Xml.dasm (-0.02 % of base)
-540 : System.Data.Odbc.dasm (-0.25 % of base)
-528 : System.IO.Ports.dasm (-1.13 % of base)
-474 : System.IO.Pipes.dasm (-1.22 % of base)
-450 : System.Reflection.MetadataLoadContext.dasm (-0.20 % of base)
-449 : System.IO.MemoryMappedFiles.dasm (-2.12 % of base)
-415 : System.Net.Primitives.dasm (-0.55 % of base)
-402 : System.Net.Mail.dasm (-0.21 % of base)
-378 : System.Net.Http.dasm (-0.05 % of base)
74 total files with Code Size differences (74 improved, 0 regressed), 198 unchanged.
Top method regressions (bytes):
9 (0.10 % of base) : System.Private.Xml.dasm - <GetTokenAsync>d__173:MoveNext():this
Top method improvements (bytes):
-300 (-6.46 % of base) : System.Drawing.Common.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.InteropServices.HandleRef,byref):int (25 methods)
-258 (-12.48 % of base) : System.Reflection.MetadataLoadContext.dasm - System.Reflection.TypeLoading.CoreTypeHelpers:GetFullName(int,byref,byref)
-192 (-6.90 % of base) : System.Drawing.Common.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.InteropServices.HandleRef,int):int (16 methods)
-144 (-9.59 % of base) : System.Security.Cryptography.Algorithms.dasm - Internal.Cryptography.AesImplementation:GetAlgorithm(int,int,int):long
-132 (-8.67 % of base) : System.Drawing.Common.dasm - System.Drawing.MacSupport:GetCGContextForView(long):System.Drawing.CarbonContext
-120 (-6.78 % of base) : System.Drawing.Common.dasm - ILStubClass:IL_STUB_PInvoke(long,byref):int (10 methods)
-100 (-4.54 % of base) : System.Drawing.Common.dasm - System.Drawing.Graphics:CopyFromScreenX11(int,int,int,int,System.Drawing.Size,int):this
-72 (-8.14 % of base) : System.Private.CoreLib.dasm - ILStubClass:IL_STUB_PInvoke():long (7 methods)
-72 (-7.19 % of base) : System.Private.CoreLib.dasm - ILStubClass:IL_STUB_PInvoke(long,long):int (6 methods)
-72 (-7.87 % of base) : System.Private.CoreLib.dasm - ILStubClass:IL_STUB_PInvoke(long) (7 methods)
-72 (-3.43 % of base) : System.DirectoryServices.Protocols.dasm - ILStubClass:IL_STUB_PInvoke(System.DirectoryServices.Protocols.ConnectionHandle,int,byref):int (6 methods)
-72 (-5.97 % of base) : System.Drawing.Common.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.InteropServices.HandleRef,byref,byref):int (6 methods)
-72 (-6.78 % of base) : System.Drawing.Common.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.InteropServices.HandleRef,long,int):int (6 methods)
-66 (-7.39 % of base) : System.Net.Sockets.dasm - ILStubClass:IL_STUB_PInvoke(long,long):int (6 methods)
-60 (-7.19 % of base) : System.Private.CoreLib.dasm - ILStubClass:IL_STUB_PInvoke(long,int):int (5 methods)
-60 (-7.19 % of base) : System.Security.Cryptography.X509Certificates.dasm - ILStubClass:IL_STUB_PInvoke(long,long):int (5 methods)
-60 (-7.45 % of base) : System.Private.CoreLib.dasm - ILStubClass:IL_STUB_PInvoke(long):long (5 methods)
-60 (-5.91 % of base) : System.Drawing.Common.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.InteropServices.HandleRef,System.Runtime.InteropServices.HandleRef,byref):int (5 methods)
-60 (-7.87 % of base) : System.Drawing.Common.dasm - System.Drawing.MacSupport:GetCGContextForNSView(long):System.Drawing.CocoaContext
-54 (-8.06 % of base) : System.Private.CoreLib.dasm - ILStubClass:IL_STUB_PInvoke():int (5 methods)
Top method regressions (percentages):
9 (0.10 % of base) : System.Private.Xml.dasm - <GetTokenAsync>d__173:MoveNext():this
Top method improvements (percentages):
-9 (-22.50 % of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.Marshal:SetLastSystemError(int)
-9 (-21.95 % of base) : System.Private.CoreLib.dasm - System.Diagnostics.Stopwatch:GetTimestamp():long
-9 (-21.95 % of base) : System.Private.CoreLib.dasm - System.Diagnostics.Stopwatch:QueryPerformanceCounter():long
-9 (-21.95 % of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.Marshal:GetLastSystemError():int
-9 (-20.93 % of base) : System.Net.NameResolution.dasm - Microsoft.Extensions.Internal.ValueStopwatch:StartNew():Microsoft.Extensions.Internal.ValueStopwatch
-9 (-20.93 % of base) : System.Net.Http.dasm - Microsoft.Extensions.Internal.ValueStopwatch:StartNew():Microsoft.Extensions.Internal.ValueStopwatch
-9 (-20.93 % of base) : System.Net.Security.dasm - Microsoft.Extensions.Internal.ValueStopwatch:StartNew():Microsoft.Extensions.Internal.ValueStopwatch
-9 (-20.93 % of base) : Microsoft.Extensions.Http.dasm - Microsoft.Extensions.Internal.ValueStopwatch:StartNew():Microsoft.Extensions.Internal.ValueStopwatch
-9 (-19.15 % of base) : System.Diagnostics.Process.dasm - System.Diagnostics.Process:SetDelayedSigChildConsoleConfigurationHandler()
-3 (-18.75 % of base) : System.Net.Http.dasm - Http2Stream:get_StatusHeaderName():System.ReadOnlySpan`1[Byte]
-3 (-18.75 % of base) : Microsoft.Extensions.DependencyModel.dasm - Microsoft.Extensions.DependencyModel.DependencyContextJsonReader:get_Utf8Bom():System.ReadOnlySpan`1[Byte]
-9 (-18.75 % of base) : System.IO.FileSystem.Watcher.dasm - Sys:GetLastError():int
-9 (-18.75 % of base) : System.Private.CoreLib.dasm - Sys:GetLastError():int
-9 (-18.75 % of base) : System.Diagnostics.Process.dasm - Sys:GetLastError():int
-9 (-18.75 % of base) : System.Net.Sockets.dasm - Sys:GetLastError():int
-3 (-18.75 % of base) : System.Memory.dasm - System.Buffers.Text.Base64:get_DecodingMap():System.ReadOnlySpan`1[SByte]
-3 (-18.75 % of base) : System.Memory.dasm - System.Buffers.Text.Base64:get_EncodingMap():System.ReadOnlySpan`1[Byte]
-3 (-18.75 % of base) : System.Drawing.Common.dasm - System.Drawing.ImageConverter:get_BMBytes():System.ReadOnlySpan`1[Byte]
-3 (-18.75 % of base) : System.Drawing.Common.dasm - System.Drawing.ImageConverter:get_PBrush():System.ReadOnlySpan`1[Byte]
-3 (-18.75 % of base) : System.Drawing.Primitives.dasm - System.Drawing.KnownColorTable:get_ColorKindTable():System.ReadOnlySpan`1[Byte]
2330 total methods with Code Size differences (2329 improved, 1 regressed), 366469 unchanged.
-------------------------------------------------------------------------------- There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed the change, can you take another look please? |
||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/*++ | ||||||||||||||||||||||||||||||||||||||
Function: | ||||||||||||||||||||||||||||||||||||||
VirtualAlloc | ||||||||||||||||||||||||||||||||||||||
|
@@ -2093,11 +2112,6 @@ void* ReserveMemoryFromExecutableAllocator(CPalThread* pThread, SIZE_T allocatio | |||||||||||||||||||||||||||||||||||||
--*/ | ||||||||||||||||||||||||||||||||||||||
void ExecutableMemoryAllocator::Initialize() | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
m_startAddress = NULL; | ||||||||||||||||||||||||||||||||||||||
m_nextFreeAddress = NULL; | ||||||||||||||||||||||||||||||||||||||
m_totalSizeOfReservedMemory = 0; | ||||||||||||||||||||||||||||||||||||||
m_remainingReservedMemory = 0; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
// Enable the executable memory allocator on 64-bit platforms only | ||||||||||||||||||||||||||||||||||||||
// because 32-bit platforms have limited amount of virtual address space. | ||||||||||||||||||||||||||||||||||||||
#ifdef HOST_64BIT | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.