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

Stack size override #24532

Merged
merged 5 commits into from
May 15, 2019
Merged

Stack size override #24532

merged 5 commits into from
May 15, 2019

Conversation

sdmaclea
Copy link

@sdmaclea sdmaclea commented May 10, 2019

Add code to override process default stack size for VM from the property bag

Fixes #21450

/cc @jkotalik

@sdmaclea sdmaclea added this to the 3.0 milestone May 10, 2019
@sdmaclea sdmaclea self-assigned this May 10, 2019
@sdmaclea sdmaclea force-pushed the StackSizeOverride branch from 3071c9c to edb1e4a Compare May 10, 2019 22:37
src/vm/threads.cpp Outdated Show resolved Hide resolved
@sdmaclea sdmaclea force-pushed the StackSizeOverride branch from edb1e4a to b981414 Compare May 11, 2019 00:43
@vitek-karas
Copy link
Member

I'm curious about the property name: OVERRIDE_DEFAULT_STACK_SIZE_4KPAGES - why 4K pages? I think it would be cleaner to simple take number of bytes and decide on rounding (probably down?). I find it funny that we require the specified value to be 4K "aligned" and then convert it to bytes internally and use it everywhere like that. What happens if we run on OS which has larger pages?

I guess what I'm saying is, why not OVERRIDE_DEFAULT_STACK_SIZE.


if ((errno == ERANGE) || (valueStr == end) || (end == nullptr) || (end[0] != 0) || (value >= max4KPages))
{
ThrowMessage("OVERRIDE_DEFAULT_STACK_SIZE_4KPAGES value parse error");
Copy link
Member

Choose a reason for hiding this comment

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

I don't know much about exceptions in the runtime... so maybe this is correct, but I find it weird that ThrowMessage is not used anywhere else as far as I can tell. And also then there's this comment:

#define ThrowMessage "Don't use this in the VM directory"

Another consideration is the error message, I would think it should be localized (as in coming from resources somewhere?).

Copy link
Author

Choose a reason for hiding this comment

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

#define ThrowMessage        "Don't use this in the VM directory" 

That is a terrible worthless define. It should be a static assert at least. Silently ignoring the error is just silly. More technical debt...

I didn't expect this to be a user facing error. I think the message will get lost anyway. It will likely become one of those E_FAIL startup errors that are so nice to debug....

Looks like this might have to become a COMPlusThrowHR...

@sdmaclea
Copy link
Author

why 4K pages?

It is arbitrary. I started with bytes, then decided 4K was the absolute minimum stack size we could ever support, and a 4K granularity was the minimum that would ever make sense. I considered bytes, 4K, 64K, 1M.

I could switch it to bytes and set a minimum stack size. I would probably arbitrarily chose 64K.

@jkotas
Copy link
Member

jkotas commented May 12, 2019

I think bytes would be better.

@jkotalik
Copy link

Similar to the UseEntryPoint feature, I think it makes sense to have an option to have an environment variable to set the stack size. It's significantly easier for a user to set it as it doesn't require using runtime properties. Thoughts?

@@ -742,6 +742,12 @@ HRESULT CorHost2::_CreateAppDomain(
pwzAppNiPaths = pPropertyValues[i];
}
else
if (wcscmp(pPropertyNames[i], W("OVERRIDE_DEFAULT_STACK_SIZE")) == 0)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Make it just DEFAULT_STACK_SIZE ? `

@sdmaclea sdmaclea merged commit 6a85ca5 into dotnet:master May 15, 2019
@sdmaclea sdmaclea deleted the StackSizeOverride branch May 15, 2019 00:34
@analogrelay
Copy link

It looks like (from the commit history) we have an environment variable 🎉. So just to confirm, the COMPLUS_DEFAULT_STACK_SIZE variable should be usable now to set the stack size?

@sdmaclea
Copy link
Author

COMPLUS_DEFAULT_STACK_SIZE variable should be usable now to set the stack size?

Yes.

@jkotas
Copy link
Member

jkotas commented May 15, 2019

It should be COMPlus_DefaultStackSize, I think.

@janvorli
Copy link
Member

It should be COMPlus_DefaultStackSize, I think.

Right

@analogrelay
Copy link

Thanks!

franksinankaya pushed a commit to franksinankaya/coreclr that referenced this pull request May 30, 2019
Add ability to override stack size on all platforms

* Add DEFAULT_STACK_SIZE property
* Make environment variable affect all platforms
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Add ability to override stack size on all platforms

* Add DEFAULT_STACK_SIZE property
* Make environment variable affect all platforms


Commit migrated from dotnet/coreclr@6a85ca5
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable overriding default stack size on Windows
6 participants