GeezerVison is showing github.com — Discussion: Criteria for upgrading worker_threads module from experimental to stable · Issue #22940 · nodejs/node
Discussion: Criteria for upgrading worker_threads module from experimental to stable #22940Labels workerIssues and PRs related to the worker_threads module and Worker API. Description
- User-space modules built on worker_threads
- Modules in citgm that exercise
worker_threads in tests
- Reports of worker_threads deployed in production
- Framework adoption
- full test coverage
- test coverage is now 100% for worker_threads JS files in core
- No flaky tests
- fix flaky test/parallel/parallel.status:test-worker-debug (Investigate flaky parallel/test-worker-debug on Windows #28106)
- fix flaky test/parallel/parallel.status:test-worker-prof
- fix flaky test/parallel/parallel.status:test-worker-syntax-error
- fix flaky test/parallel/parallel.status:test-worker-syntax-error-file
- fix flaky test/parallel/parallel.status:test-worker-memory
- Review source code for compatibility with
terminate()
- No reliance on experimental V8 APIs (
ValueSerializer in particular)
/cc @nodejs/workers Reacted by Anna Henningsen, Denis Fäcke, James M Snell, Michael Dawson, Yahor Siarheyenka, Benjamin Gruenbaum, Rotem Bar, Vincenzo Ferrari, Loreto Parisi, Joseph Gordon and 3 more Reacted by Loreto Parisi and Harshit Kumar Reacted by Loreto Parisi ActivityAyushG3112 commented on Sep 19, 2018 Question: Is the API more or less frozen? devsnek commented on Sep 19, 2018 Would be nice to see locks be stable by then too, but maybe that's a separate thing to track? addaleax commented on Sep 19, 2018 @devsnek I’d track that separately, given that it’s a fully separate API and is useful independently of Workers? joyeecheung commented on Sep 19, 2018
Question: Is the API more or less frozen?
From Node's side it's still experimental so I believe it's not frozen, but it's related to Web Workers which has a stable spec and we (kind of? correct me if I am wrong) agreed in nodejs/TSC#557 that we don't want to deviate too far from the existing design. addaleax commented on Sep 22, 2018 Fwiw, there’s also the issue of workers not playing well with fs stat watchers because their cleanup code calls its callback prematurely on the libuv side (libuv/libuv#1869) … should things like that go on the list? Trott commented on Sep 22, 2018
should things like that go on the list?
I guess if we don't want it to be stable before that's fixed, then yes. devsnek commented on Sep 22, 2018 just reading the microjob readme... So, Microjob treats Node.js threads as temporary working units: if you need to spawn a long-living thread, then you should...
I think another thing to block on is better documentation. people should be re-using threads as much as possible. benjamingr commented on Oct 3, 2018 benjamingr commented on Oct 3, 2018 Does the inspector work already? (I was away and didn't notice)
Would also be interested in getting sockets transferable - @KromDaniel has expressed interest in working on that (although I'm definitely not blocking on this) addaleax commented on Oct 4, 2018
Does the inspector work already? (I was away and didn't notice)
It should, yes. :)
Would also be interested in getting sockets transferable
I wouldn’t list that as a criterion here, but I’d also love to see that! Adressing libuv/libuv#390 would be the “hard” part here. Reacted by Benjamin Gruenbaum stevenvachon commented on Oct 4, 2018 empyrical commented on Oct 4, 2018 One thing I saw in one of the original discussions was that the module couldn't be called worker because the owner of that package name on NPM wanted to keep the name. Would workers be an acceptable option? Before moving out of experimental might be a good time to change the name to something shorter (and leaving worker_threads as an alias to the new name, because there are already user modules that use it)
cc @romansky: would you be open to letting the Node.js project use the package name workers for this? ( https://www.npmjs.com/package/workers ) guybedford commented on Oct 6, 2018 I'd like it if there could be an assessment done from a web compatibility and tooling perspective wrt to workflows around writing universal multi-threaded code.
I imagine it would be straightforward to write a browser wrapper for worker_threads, or simply have some conditional worker instantiation code between browser and Node, while sharing the main body, but I haven't gone into these details too deeply. I'd like to know someone has though, so that if there are any workflow hindrances that put a spanner in the tooling works, that these don't come up late in the day after the stability badge has long past.
I completely understand too if this is already decided as a non-goal as well, and will gladly have that discussion too.
If I've missed any of these points in previous discussions please do point out where I can read further. romansky commented on Oct 7, 2018 I'd be happy for you to have it. Let me know how to do the transfer
…Reacted by GP, Benjamin Gruenbaum, empyrical, Matt Olson and Taylor Brown addaleax commented on Feb 11, 2019
After the Worker is initialized and the user's code is running there is the option to hook into v8::Isolate::SetOOMErrorHandler()
That doesn’t get us much, as this also leads to unconditional aborts when it is called.
There is no method to check whether a Worker will abort before it's created, e.g. simply looking at available memory isn't sufficient (such as my uname -v example in the issue). Because there is a lack of visibility into Worker initialization I believe Node should be able to guarantee it won't abort until the user is able to take control.
My point was that this is true for every other type of Node.js object as well, Workers might just be one of the more resource-intensive ones. sam-github commented on Jun 18, 2019 kawpii commented on Sep 7, 2019 Any plans to upgrade to stable? addaleax commented on Sep 7, 2019 @kaushalyap In May at our Collaborator Summit we agreed that the remaining criterion before upgrading to stable would be making sure that our Web Messaging implementation matches with the Web Platform Tests for those, so I think at this point it’s only fixing #29315 to work on Windows and then we’re good to go. (It’s probably not a lot of work, but debugging on Windows sadly still takes a lot of time and effort, at least for me.) Reacted by Kaushalya Pradeep, Benjamin Gruenbaum and elerocks Reacted by elerocks and William Cooter carera commented on Sep 11, 2019 Hi all,
Thank you everyone for the awesome work around worker threads!
I am not entirely sure how to ask this, but still worth the try: When I am trying to profile an app using V8 profiler, the job executed on worker_threads does not show up in the profiles. I am using this lib: https://github.com/hyj1991/v8-profiler-next which exposes node bindings inside JS.
(see my issue: hyj1991/v8-profiler-next#9)
Is there a plan to make this work, when worker_threads are considered stable?
Thank you so much.
Cheers! 💜 benjamingr commented on Sep 11, 2019 @carera hey, first of all thank you for chiming in :]
In hyj1991/v8-profiler-next#9 (comment) it appears that slonka has confirmed that worker_threads are supported. I have also been able to profile them in the past when testing PRs related to them.
Just wondering - why are you invoking the profiler directly rather than going through the inspector and the debugger protocol? You should be able to open an inspector and do something like Profiler.enable and then call Profiler.start to start profiling and Profiler.end to stop. Do the the inspector docs help?
I think (I don't remember precisely but remember vaguely from reviewing but I can happily check for you) there should be something like a NodeRuntime domain that lets you switch to worker threads and that tools like ndb should support profiling worker threads out of the box.
There are a few things to keep in mind:
- Profiling multi-threaded applications well is in my opinion a lot more than just profiling each thread independently (which is what currently works).
- We would need help from the V8 team to enable that and they would probably need to build those tools for web-workers first.
Mostly - we have been waiting for people to be engaged and raise what they want and use cases. carera commented on Sep 11, 2019 Thank you for your swift response, @benjamingr. The use case we have is the ability to profile on demand in production without the need of running the service with any --prof or debugger flags.
That is mostly because we fear that these profiling flags have performance impact and they also generate files that continuously grow.
V8-profiler seemed to be a great idea as we could turn the profiling on/off for desired periods, such as during a production incident. Reacted by Benjamin Gruenbaum benjamingr commented on Sep 11, 2019 @carera You would open the inspector dynamically, then call Profiler.enable - that can happen dynamically and not incur a performance impact and you could even do this (with ndb for example) with a running Node.js process in production :] carera commented on Sep 11, 2019 Thank you @benjamingr again! I am not entirely sure how does ndb fall into the picture, as I am not familiar with it, but the inspector looks promising! I am gonna give it a go.
Thank you again and sorry for possibly sidetracking from this issue topic :)
Love y'all! 💜 benjamingr commented on Sep 12, 2019 @carera ndb just has built in support for debugging worker threads. You would send a SIGUSR to the process which would open the debugger than use ndb to connect to that (since that is less manual than using the debugger protocol yourself with the built in inspector module) and then that should automatically let you debug and profile worker_threads.
MetadataMetadataworkerIssues and PRs related to the worker_threads module and Worker API. DevelopmentNo branches or pull requestsIssue actions
|