This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Implement an allocator for executable (JIT) memory in PAL #2205
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change improves performance of CoreCLR with Server GC enabled by about 30% according to ASP.NET benchmarks on Linux. The table below shows number of requests per second that an ASP.NET benchmark could handle on my machine before and after the change. Pipeline Before After Improvement 16 230K Req/sec 305K Req/sec 33% 256 240K Req/sec 340K Req/sec 42% The problem was that with Server GC enabled, the GC initialization code was reserving a large chunck (about 18GB on my machine) of virtual address space during runtime initialization. Unfortunately, due to implementation details of MM on Linux, GC memory was located next to the location of libcoreclr. As a result, the runtime could not allocate memory for JIT'ed code close to the coreclr library. Because of that the JIT'ed code had to use jump stubs to call functions from the runtime (which can become very expensive, for example, for write barriers). This change fixes this issue by implementing a simple allocator that tries to reserve (during process startup) a chuck of virtual memory that is located near the coreclr library (within 2GB range) that can be later used for JIT'ed code.
@@ -3538,6 +3542,7 @@ SetErrorMode( | |||
#define MEM_MAPPED 0x40000 | |||
#define MEM_TOP_DOWN 0x100000 | |||
#define MEM_WRITE_WATCH 0x200000 | |||
#define MEM_RESERVE_EXECUTABLE 0x40000000 // reserve memory using executable memory allocator |
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.
Two extra "0"? Shouldn't this be
0x400000 or
0x10000000 or
0x1000000
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.
This was intentional because I wanted to have some buffer between the standard Windows flags and PAL specific value.
LGTM modulo the nits. |
I have addressed all code review comments. |
LGTM |
1 similar comment
LGTM |
sergiy-k
added a commit
that referenced
this pull request
Dec 3, 2015
Implement an allocator for executable (JIT) memory in PAL
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
Implement an allocator for executable (JIT) memory in PAL Commit migrated from dotnet/coreclr@0bdc646
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change improves performance of CoreCLR with Server GC enabled by about 30% according to ASP.NET benchmarks on Linux. The table below shows number of requests per second that an ASP.NET benchmark could handle on my machine before and after the change.
The problem was that with Server GC enabled, the GC initialization code was reserving a large chunk (about 18GB on my machine) of virtual address space during runtime initialization. Unfortunately, due to implementation details of MM on Linux, GC memory was located next to the location of libcoreclr. As a result, the runtime could not allocate memory for JIT'ed code close to the coreclr library. Because of that the JIT'ed code had to use jump stubs to call functions from the runtime (which can become very expensive, for example, for write barriers).
This change fixes this issue by implementing a simple allocator that tries to reserve (during process startup) a chunk of virtual memory that is located near the coreclr library (within 2GB range) that can be later used for JIT'ed code.