-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement setStackSize
on Windows
#10737
Conversation
0426ad0
to
a41f422
Compare
@poweredbypie Thanks for trying this, especially the VM testing! Seeing https://stackoverflow.com/questions/156510/increase-stack-size-on-windows-gcc, it looks like we can use that in conjunction with this function, and then do the same size size as on Unix? |
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.
per my comment above
I've implemented the linker flag and removed the conditional compilation so both Unix and Windows guarantee 64 MB. However, I've set the linker flag to commit 128 MB of stack rather than 64, since it seems to fail when only set to 64. I've tried with the following tests: |
Makefile
Outdated
# Increase the default reserved stack size to 128 MB so Nix doesn't run out of space | ||
GLOBAL_LDFLAGS += -Wl,--stack,134217728 |
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.
Can we do this per executable? So change src/nix/local.mk
? The one with the unit tests can be adjusted too.
Also maybe do the trick in https://stackoverflow.com/questions/1926063/how-do-i-perform-arithmetic-in-a-makefile to make things easier to read?
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.
Can we do this per executable? So change
src/nix/local.mk
? The one with the unit tests can be adjusted too.
Done, I added the flag to nix and all the libnix*-tests
binaries. However, I'm not sure if that's what you're referring to. Do you mean all the tests or just the libnixutil-tests
binary?
Also maybe do the trick in https://stackoverflow.com/questions/1926063/how-do-i-perform-arithmetic-in-a-makefile to make things easier to read?
Done!
@poweredbypie Thanks for all your testing work! Yes it does seem that the "user portion" of the stack is a bit smaller. If you can make a 65 or 66 MiB work, I do agree that would be best! |
0fcbab3
to
1c83b4f
Compare
Sure. 65 MB seems to work fine: |
This way we can commit the same amount of stack size (64 MB) without a conditional. Includes nix, libnixexpr-tests, libnixfetchers-tests, libnixstore-tests, libnixutil-tests.
1c83b4f
to
0b7da09
Compare
https://learn.microsoft.com/en-us/cpp/build/reference/stack-stack-allocations?view=msvc-170 says
That definitely matches my intuition. Can we remove this from the libraries, or did you find it does in fact make a difference when testing? |
Sorry, I'm not sure what you mean. I added the flags to the test binaries, which are still exe files: |
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.
Sorry! I misread
Motivation
See #10540.
Context
This implements setStackSize for Nix using MinGW, with the strategy described in #10540 (SetThreadStackGuarantee). I've tested this on a Windows 10 LTSC VM through NixOS without any issues.
However, I'm not sure if this change is really required. It seems from a bit of skimming that Windows allocates 1 MB of stack space for each thread by default (specified here), and it doesn't seem like that number is modifiable after compilation. As a result, the
setStackSize
call inmain
doesn't work with the 64 MB of stack space requested, as on Unix systems.I've opted to request 1 MB of stack space as a result, but I'm unsure if this is even a useful request, considering the default thread's stack size.
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.