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 into
dotnet: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 into
dotnet:mainfrom
tmds:mono_default_stack_size

Conversation

@tmds

@tmds tmds commented Feb 19, 2026

Copy link
Copy Markdown
Member

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

tmds commented Feb 19, 2026

Copy link
Copy Markdown
Member Author

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

hamarb123 commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

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?

Comment thread src/mono/mono/utils/mono-threads-posix.c Outdated
@jkotas

jkotas commented Feb 19, 2026

Copy link
Copy Markdown
Member

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

Comment thread src/mono/mono/utils/mono-threads-posix.c Outdated
… 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

tmds commented Feb 23, 2026

Copy link
Copy Markdown
Member Author

@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

@akoeplinger akoeplinger left a comment

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.

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

Comment thread src/mono/mono/metadata/threads.c Outdated
Comment thread src/mono/mono/utils/mono-threads-wasm.c
tmds and others added 2 commits February 24, 2026 10:38
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
@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

tmds commented Feb 24, 2026

Copy link
Copy Markdown
Member Author

I've updated the title/description.

Thanks for reviewing and feedback @akoeplinger and @jkotas!

@akoeplinger
akoeplinger merged commit 4a31f31 into dotnet:main Feb 25, 2026
73 of 75 checks passed
iremyux pushed a commit to iremyux/dotnet-runtime that referenced this pull request Mar 2, 2026
…read_DefaultStackSize for setting stack size. (dotnet#124588)

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 dotnet#124368.

@jkotas @akoeplinger @hamarb123 ptal.

---------

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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