Uh oh!
There was an error while loading. Please reload this page.
worker: reset Isolate stack limit after entering Locker - #31593
Conversation
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)
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Feb 1, 2020
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Feb 1, 2020
Trott
commented
Feb 2, 2020
The test added here failed on Win2012 R2 + VS2019 in CI. Not sure if it's fail-every-time or flaky, but either way, probably warrants investigation before landing..... |
addaleax
commented
Feb 4, 2020
@Trott thanks for checking – I’ve updated the PR, leaving some wiggle room for inaccuracies. |
nodejs-github-bot
commented
Feb 7, 2020
nodejs-github-bot
commented
Feb 7, 2020
nodejs-github-bot
commented
Feb 7, 2020
nodejs-github-bot
commented
Feb 8, 2020
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>
addaleax
commented
Feb 8, 2020
Landed in 9111e02 |
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>
ulrichb
commented
Apr 26, 2020
@addaleax Could you explain the effect of this change? Dos this mean |
addaleax
commented
Apr 26, 2020
@ulrichb Yes, that is correct. The stack size in Workers that V8 knows about is now the actual stack size that was used when creating the Workers. There is currently no way so set We’ve considered making the stack size configurable through the |
Thanks for your reply! Okay, I understand. Atm. this works for me because the hard-coded WT limit (4 MB?) is way larger than the default But to be future-proof, I'd really hope for a My use case: I'm hosting the TypeScript compiler in a WT (which is necessary because it is heavily CPU bound + non-async) and the TS compiler does a lot of recursion, which can possibly hit the stack limit dependent on user input :( Here is a synthetic example , which hits the recursion limit with N > ~2500 on my machine (TS v3.8.3): importfsfrom"fs";importworkerThreadsfrom"worker_threads";importtsfrom"typescript";if(workerThreads.isMainThread){constworker=newworkerThreads.Worker(__filename);worker.on("exit",code=>{console.log(`Worker stopped with exit code ${code}`);});}else{console.log("Hello from worker, TS version: "+ts.version);fs.writeFileSync("TempLargeTSFile.ts",`class MyBuilder { method(): this { return this; } }export default new MyBuilder()${[...Array(4000)].map(()=>` .method()`).join("\n")};`);constprogram=ts.createProgram(["TempLargeTSFile.ts"],{types: []});constemitResult=program.emit();constdiagnostics=[...ts.getPreEmitDiagnostics(program), ...emitResult.diagnostics];console.log('diagnostics',diagnostics);} |
addaleax
commented
Apr 26, 2020
@ulrichb So to be clear, you are using
I can just open a PR and we can see how that goes. |
Add `stackSizeMb` to the `resourceLimit` option group. Refs: nodejs#31593 (comment)
addaleax
commented
Apr 27, 2020
ulrichb
commented
Apr 27, 2020
Yes.
Okay, so the actual stack limit is dependent on the OS process, and
Nice. Thank you! |
addaleax
commented
Apr 27, 2020
Yes, but only if you set it to a lower value than the actual stack size. 👍 |
Add `stackSizeMb` to the `resourceLimit` option group. Refs: #31593 (comment) PR-URL: #33085 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add `stackSizeMb` to the `resourceLimit` option group. Refs: #31593 (comment) PR-URL: #33085 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add `stackSizeMb` to the `resourceLimit` option group. Refs: #31593 (comment) PR-URL: #33085 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
It turns out that using
v8::Lockerundoes the effects ofpassing an explicit stack limit as part of the
Isolate’sresource constraints.
Therefore, reset the stack limit manually after entering a Locker.
Refs: #26049 (comment)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes