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

restrict memory limit by taking VM into consideration#17177

Merged
Maoni0 merged 1 commit into
dotnet:masterfrom
Maoni0:restrict_vm
Mar 27, 2018
Merged

restrict memory limit by taking VM into consideration#17177
Maoni0 merged 1 commit into
dotnet:masterfrom
Maoni0:restrict_vm

Conversation

@Maoni0
Copy link
Copy Markdown
Member

@Maoni0 Maoni0 commented Mar 24, 2018

for 32-bit processes when we look at the memory limit for the process we also should take VM into consideration. right now the VM limit is not implemented on PAL so this is only for non PAL.

@Maoni0 Maoni0 requested review from davmason, janvorli and sywhang March 24, 2018 00:52
Comment thread src/vm/gcenv.os.cpp
{
if (hinstKernel32 != 0)
{
// We can also free the lib here - if we are limited by VM we will not be calling
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to load K32GetProcessMemoryInfo dynamically? According to MSDN, it is always available in kernel32.dll starting with Windows 7. The dynamic loading looks like leftover from times when we have supported earlier OSes.

And CoreCLR.dll always depends on kernel32.dll, so we are not getting anything by loading it dynamically.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked; this code was changed a lot by various people and they gradually got rid of the dynamic checks...but somehow the last checkin left this one...which I didn't CR 'cause I was out (but you did :-))...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar cleanups tend to be done gradually. People do an iterations and then move on, even though there is more that can be cleaned up.

I have just pointed this out since you are adding more code here that does not seem necessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's only unnecessary if the dynamic check isn't there. do you remember if there was a reason why this particular dynamic check was left there? it would seem it's easier to just remove them all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#8624 was about removing API sets dependencies.

The dynamic check for K32GetProcessMemoryInfo was there even on the non-API set (ie !FEATURE_CORECLR) codepath before the change, and I guess that's why it was kept even with API set dependencies removed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok...I'm going to open an issue to track this - I also see that there're unnecessary things like "GCIsProcessInJob = &(::IsProcessInJob);", why not just call IsProcessJob if we are sure it's there? also the standalone gc's implementation still has all the checks which seem unnecessary.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Mar 25, 2018

Also, this change should be replicated in https://github.com/dotnet/coreclr/blob/master/src/gc/windows/gcenv.windows.cpp for standalone GC.

@Maoni0
Copy link
Copy Markdown
Member Author

Maoni0 commented Mar 25, 2018

ah yeah, I'll add that. thanks!

@janvorli
Copy link
Copy Markdown
Member

@Maoni0 the GetProcessMemoryLoad does clipping of ullAvailPhys by ullAvailVirtual. I understand that this change adds clipping by the job limits, so it seems it would be nice to change the title/ description of the PR to make it clear.

@Maoni0
Copy link
Copy Markdown
Member Author

Maoni0 commented Mar 26, 2018

I understand that this change adds clipping by the job limits

@janvorli not sure what you meant? this PR adds clipping even when you are not using a job...it's just to restrict the memory by another means, ie, via VM.

@janvorli
Copy link
Copy Markdown
Member

@Maoni0 we were already clipping the physical memory via VM before, even for PAL. See the GetProcessMemoryLoad implementation here: https://github.com/dotnet/coreclr/blob/master/src/vm/corhost.cpp#L2957-L2962

@Maoni0
Copy link
Copy Markdown
Member Author

Maoni0 commented Mar 26, 2018

@janvorli wow that's quite a dangerous thing to do - so we are returning the available VM as available physical mem, yet we do not modify the memory load to reflect this...

@janvorli
Copy link
Copy Markdown
Member

@Maoni0 it has been like that for a long time if not forever - the code has not changed since the initial publishing of opensource coreclr.

@Maoni0
Copy link
Copy Markdown
Member Author

Maoni0 commented Mar 27, 2018

@janvorli I'm going to get rid of it and use the logic in my PR. do you see a problem with that for non Windows platform?

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Mar 27, 2018

FWIW, this code was added on 2003/05/10 by weiwenli. There are no further details on why it was added.

I agree that it looks wrong. I do not see a problem with getting rid of it.

@Maoni0
Copy link
Copy Markdown
Member Author

Maoni0 commented Mar 27, 2018

#17243

@Maoni0
Copy link
Copy Markdown
Member Author

Maoni0 commented Mar 27, 2018

LGTY? 😸

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