Uh oh!
There was an error while loading. Please reload this page.
worker: set stack size for worker threads - #26049
Conversation
addaleax
commented
Feb 11, 2019
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
For platforms where 4MB is not the default stack size, does this prove as an added memory pressure, and if so, should we document this?
There was a problem hiding this comment.
does this prove as an added memory pressure
@gireeshpunathil Not on most platforms in their default configuration, I assume – usually, memory pages are only actually committed when first accessed.
I wouldn’t explicitly document this, as it shouldn’t make much of a difference for users.
There was a problem hiding this comment.
Is it possible that some compilers decide to take this address from the caller thread's stack as opposed to the current thread's stack? I guess it should not, but I am not up-to-date with compiler optimizations.
There was a problem hiding this comment.
The compiler doesn’t know whether there are different threads involved here. And if there’s something invalid about this, then V8 already has the same problem in their code (which I assume they don’t).
gireeshpunathil
commented
Feb 12, 2019
Should / Could we also expose this into the JS land? say: |
Uh oh!
There was an error while loading. Please reload this page.
bnoordhuis
commented
Feb 12, 2019
Too small or too big stack sizes can be dangerous and the limits depend on the platform and other factors. There's also the question of how a programmer can know what a reasonable stack size is for a given workload without knowing all about Node's inner workings, or the add-ons they use. |
addaleax
commented
Feb 13, 2019
This is so we can inform V8 about a known limit for the stack. Otherwise, on some systems recursive functions may lead to segmentation faults rather than “safe” failures.
b1c60cb to
23c4573Compareaddaleax
commented
Feb 13, 2019
Rebased, new CI: https://ci.nodejs.org/job/node-test-pull-request/20763/ |
addaleax
commented
Feb 13, 2019
This is so we can inform V8 about a known limit for the stack. Otherwise, on some systems recursive functions may lead to segmentation faults rather than “safe” failures. PR-URL: #26049 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This is so we can inform V8 about a known limit for the stack. Otherwise, on some systems recursive functions may lead to segmentation faults rather than “safe” failures. PR-URL: #26049 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
ulrichb
commented
Jan 30, 2020
So, there is now a hard-coded stack size limit of 4 MB, right? Is there any possibility to override this limit (e.g. using |
addaleax
commented
Jan 30, 2020
@ulrichb There isn’t, currently – as you can see, there was a brief discussion above about that: #26049 (comment) If you’d like to see a feature like that, could you open a new issue and ideally provide some information about your use case? |
ulrichb
commented
Jan 31, 2020
@addaleax I'm not quite sure why, but it seems that the stack limit can be influenced by the V8 switch BTW: My use case is that I'm hosting the TypeScript compiler in a worker thread which does a lot of recursion, and this hit the stack limit for really big files (I have generated code files with ~ 20kLOC.) |
... oh and I used @addaleax Any ideas? Do the two values ( |
addaleax
commented
Jan 31, 2020
@ulrichb So…
I’m not sure what to say except that I fully agree with you – this is strange. I feel like One thing that I can tell you from anecdotal experience is that I’ve also been in situations in which lowering |
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: nodejs#26049 (comment)
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: #26049 (comment) PR-URL: #31593 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: #26049 (comment) PR-URL: #31593 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: #26049 (comment) PR-URL: #31593 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: #26049 (comment) PR-URL: #31593 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: #26049 (comment) PR-URL: #31593 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
(The first commit is #26037.)This is so we can inform V8 about a known limit for the stack.
Otherwise, on some systems recursive functions may lead to
segmentation faults rather than “safe” failures.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes