Skip to content

Mono: increase default stack size on s390x/ppc64le; support DOTNET_Thread_DefaultStackSize for setting stack size.#124588

Merged
akoeplinger merged 5 commits intodotnet:mainfrom
tmds:mono_default_stack_size
Feb 25, 2026
Merged

Mono: increase default stack size on s390x/ppc64le; support DOTNET_Thread_DefaultStackSize for setting stack size.#124588
akoeplinger merged 5 commits intodotnet:mainfrom
tmds:mono_default_stack_size

Conversation

@tmds
Copy link
Member

@tmds tmds commented Feb 19, 2026

This increases the default stack size on s390x and ppc64le. Due to missing implementation for tail call optimization, the vmr build exhaust the stack while building the fsharp repo. With an 8MB stack, the build can complete.

Additionally this adds support for a user to control the stack size using the DOTNET_Thread_DefaultStackSize envvar.

Fixes #124368.

@jkotas @akoeplinger @hamarb123 ptal.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 19, 2026
@tmds
Copy link
Member Author

tmds commented Feb 19, 2026

Per my comments in #124368, I also want to take a closer look at the Alpine/Musl (under ENSURE_PRIMARY_STACK_SIZE) implementation and probably suggest a change. That will be for another day/PR.

My main interest is to have this change so that the F# compiler doesn't run out of stack space while compiling fsharp repo during the .NET build on ppc64le and s390x (dotnet/fsharp#19286).

@hamarb123
Copy link
Contributor

hamarb123 commented Feb 19, 2026

Should we consider just using getrlimit on coreclr/naot also on all unix platforms? macOS defaults to 8MB for main thread by default (from that value), but then 512kB for secondary threads - we currently override manually to 1.5MB, but maybe it makes sense to just use logic this everywhere (that way it's user-controllable, consistent across all .NET on Unix, etc.)? Thoughts @tmds @jkotas?

@jkotas
Copy link
Member

jkotas commented Feb 19, 2026

Should we consider just using getrlimit on coreclr/naot also on all unix platforms? macOS defaults to 8MB for main thread by default (from that value), but then 512kB for secondary threads - we currently override manually to 1.5MB, but maybe it makes sense to just use logic this everywhere

I am hesitant to bump the default stack sizes further. This was discussed before in #98007

… config through DOTNET_Thread_DefaultStackSize envvar.
@tmds tmds force-pushed the mono_default_stack_size branch from fe0e2f5 to 0dd5dcd Compare February 23, 2026 09:02
@tmds
Copy link
Member Author

tmds commented Feb 23, 2026

@jkotas @akoeplinger I've made changed based on your feedback. Please take another look.

@tmds tmds requested a review from lateralusX as a code owner February 24, 2026 05:27
Copy link
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

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

LGTM with small comments. please fix the PR description/title

@tmds tmds changed the title Mono: mono-threads-posix: use RLIMIT_STACK for default stack size. Mono: increase default stack size on s390x/ppc64le; support DOTNET_Thread_DefaultStackSize for setting stack size. Feb 24, 2026
@tmds
Copy link
Member Author

tmds commented Feb 24, 2026

I've updated the title/description.

Thanks for reviewing and feedback @akoeplinger and @jkotas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-meta-mono community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default stack size Mono vs CoreCLR

4 participants