| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@addaleax build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/2889/pipeline |
Sorry, something went wrong.
|
What happens if the worker itself starts a new worker? |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM though I have some questions
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe we can pass the limits back here as well to display them in the error messages?
Sorry, something went wrong.
There was a problem hiding this comment.
Do you have suggestions for how/when to pass them back? I don’t think you’re thinking about callback arguments, right?
Sorry, something went wrong.
There was a problem hiding this comment.
If we have those as AliasedBuffers we could pass them back here right? (Or is that not guaranteed to be valid at this point?)
Sorry, something went wrong.
|
In case you missed it, I'll ask again: What happens if the worker itself starts a new worker? |
Sorry, something went wrong.
|
@targos - by looking at the current design, I guess:
yes, through this interface
yes
no |
Sorry, something went wrong.
|
Definitely like the direction on this. And I like the way the failure condition is handled. The one thing that's missing is: how would a worker know what it's limits are without (as you do in the tests) passing those in out of band. |
Sorry, something went wrong.
|
Any way to limit CPU usage? |
Sorry, something went wrong.
|
@jasnell @joyeecheung I guess we could make the resource limits available on the Worker object in the parent thread and in the child thread on the worker_threads exports object. I think that would cover both of your concerns, right? In that case the main question for me would be, is there anything we could/should do for non-Worker threads? Should we just (inaccurately) report Infinity everywhere, or not provide a resourceLimits object at all, or somehow try to get the actual limits? @targos Yeah, the options are independent for each Worker, in the way that @gireeshpunathil explained.
@YurySolovyov Not in this PR, sorry. That might also be pretty complex to implement, because we don’t have the VM available to do this for us. |
Sorry, something went wrong.
|
How does the diagnostic report work wrt. workers? Are the resource limits being added here something that could be added to the report? |
Sorry, something went wrong.
|
@richardlau The diagnostic report is clueless about Workers (see also #26293). But yes, when they add support, I think it makes sense to include the data. |
Sorry, something went wrong.
|
@addaleax seems like this requires a rebase. |
Sorry, something went wrong.
|
@jasnell @joyeecheung Before I rebase this … any thoughts on #26628 (comment)? |
Sorry, something went wrong.
I would go with not providing the object at all. It's easier to start small and known limitations are better than..known bugs? |
Sorry, something went wrong.
|
I'm cleaning out a few old PRs 🧹. I'm closing this due to inactivity. Please re-open if needed! |
Sorry, something went wrong.
|
I don't really see any reason why this could not have landed, don't see any blockers. On the other hand, I find great value for this PR as it provides fine grained control over the worker's execution environment - something that can be leveraged in workloads that means a lot (such as cloud) pinging @addaleax to see if I missed something. |
Sorry, something went wrong.
|
@joyeecheung @gireeshpunathil I’ve rebased this and made the resource constraints available as an object on both the worker_threads module and the Worker instance as suggested above… Could you take another look? |
Sorry, something went wrong.
Sorry, something went wrong.
| dest._maxListeners = destMaxListeners; | ||
| } | ||
|
|
||
| const resourceLimitsArray = new Float64Array(kTotalResourceLimitCount); |
There was a problem hiding this comment.
Is there a reason not to reuse resourceLimitsRaw here?
Although if we expose makeResourceLimits from this file and calculate the publicly exposed resourceLimits from lib/worker_threads.js instead it makes more sense to use two arrays in case someone created a worker internally with a resource limit..somehow.
Sorry, something went wrong.
There was a problem hiding this comment.
Practically speaking, yes, the reason is that resourceLimitsRaw is currently not defined in the main thread. And given that this is a very small typed array, I’m okay with that. If you’re concerned about the extra resource usage, I’d probably prefer changing this to not be a static variable and instead generate one for each call to parseResourceLimits()?
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM (the comment above was a nit)
Sorry, something went wrong.
| &loop_, | ||
| w->platform_); | ||
| CHECK_NOT_NULL(isolate); | ||
| Isolate::CreateParams params; |
There was a problem hiding this comment.
For my own understanding...WorkerThreadData is actually closer to NodeMainInstance for the main thread even though we don't have an equivalent abstraction of Worker for the main thread at the moment? (This was my impression when I tried with #29925 locally but I decided to take some more time to figure out a proper class hierarchy before moving forward..)
I wonder whether it makes sense to have Environment points to a base class of Worker and MainThread (?) if they have a longer life time than Environment.
Sorry, something went wrong.
There was a problem hiding this comment.
For my own understanding...WorkerThreadData is actually closer to NodeMainInstance for the main thread even though we don't have an equivalent abstraction of Worker for the main thread at the moment? (This was my impression when I tried with #29925 locally but I decided to take some more time to figure out a proper class hierarchy before moving forward..)
It is somewhat similar, yes.
I wonder whether it makes sense to have Environment points to a base class of Worker and MainThread (?) if they have a longer life time than Environment.
What would we use that for? And how would that fit into the embedder API? Both Workers and the main thread have a lifetime longer than the Environment, but only very slightly so…
Sorry, something went wrong.
There was a problem hiding this comment.
For example, Worker, NodeMainInstance and Environment all keep copies of arguments and exec arguments. We could reduce the duplication by only keeping them in Worker and MainThread. There seem to be a lot of duplication along the hierarchy at the moment..
Sorry, something went wrong.
There was a problem hiding this comment.
I would be careful about that… deduplication is nice but right now moving towards a better embedder API is my primary goal, and linking from Environment to a superclass of Worker and NodeMainInstance sounds a bit fragile
Sorry, something went wrong.
There was a problem hiding this comment.
If anything...I think a public version of that super class could be a good base for a newer set of better embedder APIs? (but maybe it's just a crazy idea, I have not given too much thought into it).
Sorry, something went wrong.
Sorry, something went wrong.
Allow specifying resource limits for the JS engine instance created as part of a Worker. PR-URL: #26628 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Allow specifying resource limits for the JS engine instance created as part of a Worker. PR-URL: #26628 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Notable changes:
* addons:
* Deprecate one- and two-argument `AtExit()`. Use the three-argument
variant of `AtExit()` or `AddEnvironmentCleanupHook()` instead
(Anna Henningsen) nodejs#30227
* child_process,cluster:
* The `serialization` option is added that allows child process
IPC to use the V8 serialization API (to e.g., pass through data
types like sets or maps) (Anna Henningsen)
nodejs#30162
* deps:
* Update V8 to 7.9
* Update `npm` to 6.13.0 (Ruy Adorno)
nodejs#30271
* embedder:
* Exposes the ability to pass cli flags / options through an API
as embedder (Shelley Vohr)
nodejs#30466
* Allow adding linked bindings to Environment (Anna Henningsen)
nodejs#30274
* esm:
* Unflag --experimental-modules (Guy Bedford)
nodejs#29866
* stream:
* Add `writable.writableCorked` property (Robert Nagy)
nodejs#29012
* worker:
* Allow specifying resource limits (Anna Henningsen)
nodejs#26628
* v8:
* The Serialization API is now stable (Anna Henningsen)
nodejs#30234
PR-URL: nodejs#30547
Notable changes:
* addons:
* Deprecate one- and two-argument `AtExit()`. Use the three-argument
variant of `AtExit()` or `AddEnvironmentCleanupHook()` instead
(Anna Henningsen) #30227
* child_process,cluster:
* The `serialization` option is added that allows child process
IPC to use the V8 serialization API (to e.g., pass through data
types like sets or maps) (Anna Henningsen)
#30162
* deps:
* Update V8 to 7.9
* Update `npm` to 6.13.0 (Ruy Adorno)
#30271
* embedder:
* Exposes the ability to pass cli flags / options through an API
as embedder (Shelley Vohr)
#30466
* Allow adding linked bindings to Environment (Anna Henningsen)
#30274
* esm:
* Unflag --experimental-modules (Guy Bedford)
#29866
* stream:
* Add `writable.writableCorked` property (Robert Nagy)
#29012
* worker:
* Allow specifying resource limits (Anna Henningsen)
#26628
* v8:
* The Serialization API is now stable (Anna Henningsen)
#30234
PR-URL: #30547
Allow specifying resource limits for the JS engine instance created as part of a Worker. PR-URL: #26628 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Allow specifying resource limits for the JS engine instance created as part of a Worker. PR-URL: #26628 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
|
A current problem with this approach is that you can't have a custom heap size for the parent process and the worker_threads. To customize the worker's heaps, you cannot customize the parent process's heap via CLI in any way. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Allow specifying resource limits for the JS engine instance created as part of a Worker.
/cc @nodejs/workers
Checklist