Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add Large pages support in GC #23251

Merged
merged 1 commit into from
Apr 8, 2019
Merged

Conversation

mjsabby
Copy link

@mjsabby mjsabby commented Mar 14, 2019

@mjsabby
Copy link
Author

mjsabby commented Mar 14, 2019

I'm thinking if a better error message should be presented if SeLockMemoryPrivilege is missing as opposed to returning OutOfMemory. My personal opinion is that documentation should be good enough to use this advanced feature rather than plumbing a specific error message out of the runtime.

But maybe we could tackle it in the host or CLI?

@mjsabby
Copy link
Author

mjsabby commented Mar 14, 2019

@Maoni0 I was wrong, Linux does have a concept of Reserve and Commit. PROT_NONE flag in the mmap call is like VirtualReserve. So I have to fix my code accordingly.

src/gc/env/gcenv.os.h Outdated Show resolved Hide resolved
src/gc/gc.cpp Outdated Show resolved Hide resolved
src/gc/unix/gcenv.unix.cpp Outdated Show resolved Hide resolved
src/gc/gc.cpp Outdated Show resolved Hide resolved
@Maoni0
Copy link
Member

Maoni0 commented Mar 14, 2019

@mjsabby one thing I missed was we should simply not do anything for gc_heap::decommit_heap_segment_pages 'cause our premise is you grab large pages upfront and don't let them go. I suspect you will get an error if you try to decommit on windows anyway. you could do

void gc_heap::decommit_heap_segment_pages (heap_segment* seg,
                                           size_t extra_space)
{
    if (use_large_pages_p)
        return;

src/vm/gcenv.os.cpp Outdated Show resolved Hide resolved
@mjsabby
Copy link
Author

mjsabby commented Mar 25, 2019

I have to introduce OpenProcessToken, AdjutTokenPrivileges and LookupPrivilegeValue for the Windows build. I'm going to do LoadLibrary advapi32 and then resolve those functions. I could also put them in utilcode but I don't think there is any utilcode dependency in the GC->EE/OS interface today.

@janvorli
Copy link
Member

I'm going to do LoadLibrary advapi32 and then resolve those functions.

I don't see a reason for using LoadLibrary for these, you can use them directly. They are supported since Windows XP.

@janvorli
Copy link
Member

OK, I can see you have already done it that way.

@mjsabby mjsabby force-pushed the largePagesInGC branch 6 times, most recently from bbfed48 to 86b01c7 Compare March 27, 2019 06:52
@mjsabby
Copy link
Author

mjsabby commented Mar 27, 2019

@Maoni0 What are your thoughts on hard limit + numa awareness + now large pages? I'm thinking to start with we keep Large Pages NUMA-unaware, otherwise it gets a bit complicated where and how much should the memory be split and commuted at startup. Already the multiple heaps overcommits by 3X I think.

For 3.0 maybe we start with GCHardLimit + Large Pages does a 3X overcommit at startup then in the future we add configs for splitting the memory across LOH, SOH + NUMA Nodes?

@Maoni0
Copy link
Member

Maoni0 commented Mar 28, 2019

For 3.0 maybe we start with GCHardLimit + Large Pages does a 3X overcommit at startup

this sounds fine to me if it's fine with you since you are our 1st customer for this :) also I'm working on reducing this 3x to 2x.

then in the future we add configs for splitting the memory across LOH, SOH + NUMA Nodes?

most likely we wouldn't need another config - it'll just be improved naturally in the future versions.

@mjsabby mjsabby force-pushed the largePagesInGC branch 4 times, most recently from 603cce1 to 77efbd4 Compare March 29, 2019 04:34
@mjsabby mjsabby changed the title [WIP] Add Large pages support in GC Add Large pages support in GC Mar 29, 2019
@mjsabby
Copy link
Author

mjsabby commented Mar 29, 2019

This is ready for review again.

After this change, the situation will be:

Memory Type Windows Linux
GC Heap ✔️
Card Table
Handle Table
Jitted Code
Other runtime heaps

Next up will be Large Pages support for the GC Heap on Linux.

Documentation Items:

(1) Noting that GCHeapHardLimit is required (GCHeapHardLimit takes input as hex bytes)
(2) SeLockMemoryPrivelege notes for Windows.
(3) For Linux we may have to talk about /proc/sys/vm/overcommit_memory which can be there on some distros, I'm not sure on the implications yet.
(4) MiniDump will be the size of the preallocated gc heap + some ... so they will be quite a bit larger.

src/gc/gc.cpp Outdated Show resolved Hide resolved
@Maoni0
Copy link
Member

Maoni0 commented Apr 2, 2019

LGTM - comments above.

src/gc/unix/gcenv.unix.cpp Outdated Show resolved Hide resolved
src/gc/unix/gcenv.unix.cpp Show resolved Hide resolved
src/gc/windows/gcenv.windows.cpp Outdated Show resolved Hide resolved
src/gc/windows/gcenv.windows.cpp Outdated Show resolved Hide resolved
src/vm/gcenv.os.cpp Outdated Show resolved Hide resolved
src/vm/gcenv.os.cpp Outdated Show resolved Hide resolved
@mjsabby mjsabby force-pushed the largePagesInGC branch 2 times, most recently from 574b9af to 28ae9ab Compare April 3, 2019 07:00
@mjsabby
Copy link
Author

mjsabby commented Apr 4, 2019

@Maoni0 @janvorli I've made the requested updates, although I'm still trying to see why my feature detection for restricting to Linux TLB isn't working as expected and failing the macOS build.

src/gc/unix/gcenv.unix.cpp Outdated Show resolved Hide resolved
@mjsabby mjsabby force-pushed the largePagesInGC branch 2 times, most recently from ad544ed to ae4f3f1 Compare April 4, 2019 23:49
@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

/azp run coreclr-ci

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

How does one trigger these CI jobs again?

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

@dotnet-bot test coreclr-ci

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

@dotnet-bot test Ubuntu x64 Checked CoreFX Tests

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

@dotnet-bot test coreclr-ci (Test Pri0 Windows_NT x64 checked)

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

@Maoni0 @janvorli Updated with your feedback.

@Maoni0
Copy link
Member

Maoni0 commented Apr 5, 2019

LGTM.

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

The coreclr-ci says the following:

Failed: 0 (0.00 %)
Passed: 35,542 (100.00 %)
Other: 0 (0.00 %)
Total: 35,542

But it still marked as failed.

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

Looks like the error is

##[Error 1]
The agent: Hosted macOS 8 lost communication with the server. Verify the machine is running and has a healthy network connection. For more information, see: https://go.microsoft.com/fwlink/?linkid=846610

@mjsabby
Copy link
Author

mjsabby commented Apr 5, 2019

@dotnet-bot test coreclr-ci (Test Pri0 OSX x64 checked)

@mjsabby mjsabby force-pushed the largePagesInGC branch 2 times, most recently from 2612370 to d36896f Compare April 6, 2019 20:17
@janvorli janvorli merged commit 1874101 into dotnet:master Apr 8, 2019
@mjsabby mjsabby deleted the largePagesInGC branch April 8, 2019 20:53
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants