-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Allow stack size to be configured #110455
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
Allow stack size to be configured #110455
Conversation
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs
Outdated
Show resolved
Hide resolved
We have (undocumented) |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs
Outdated
Show resolved
Hide resolved
Thanks. This works on Windows, it is not working for me on Linux. On windows I checked against kernel32 GetCurrentThreadStackLimits. On linux I checked against strace. |
It works for musl libc (musl libc is used e.g. by Alpine Linux). glibc that is used by the most popular Linux distros like Ubuntu does not respect value set by |
Github status is stuck in "Checking for ability to merge automatically…". Could you please rebase against main and force push? Hopefully, it is going to reset the status. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs
Outdated
Show resolved
Hide resolved
94b687c
to
b6fd3f7
Compare
I think we should look at this in the context of #113344: Here's a couple questions I have:
If so, I can add the CoreCLR version so that we can also resolve #113344 and we can doc it. Cc @kouvel @AaronRobinsonMSFT for opinion |
The naming looks good as it's consistent with:
|
@MichalStrehovsky See #113344 also.
I didn't see the
This was a source of confusion on a partner team who had been assuming it was radix 10 for about 6 years. I think having it as radix 16 is fine, but we need to document this properly at https://learn.microsoft.com/dotnet/core/runtime-config/threading. |
Seems reasonable to me. |
It's |
CoreCLR already has a |
Made this change and standardized on I left DEFAULT_STACK_SIZE as is. We could probably delete it in favor of the new System.Threading.DefaultStackSize. |
@VSadov is this something you'd be able to review? Could you please have a look? |
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.
LGTM.
We still read |
My point is that we have changed |
if (g_pRhConfig->ReadConfigValue("Thread_DefaultStackSize", &uiStacksize) | ||
|| g_pRhConfig->ReadKnobUInt64Value("System.Threading.DefaultStackSize", &uiStacksize)) | ||
{ | ||
if (uiStacksize < maxStack || uiStacksize >= minStack) |
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.
Why || and not &&. I assume it is always true now?
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.
Good catch! #118077
Good catch! #118076 |
EDIT: this has been extended to also work with CoreCLR-VM so that we can resolve #113344 with it.
If a native AOT compiled application can lower its allocated memory, more scenarios that are memory sensitive can use it.
The default stack size can be excessive for simple applications and can significantly contribute to the RSS.
For linux, there is the ulimit command, and this is respected, but it can be too broad.
With this trivial code:
On linux with the default stack size of 8mb, RSS measured at 5916.
With setting the stack size to 1mb, the RSS measured at 3428.
Roughly a 40% decrease.