-
Notifications
You must be signed in to change notification settings - Fork 97
src: prepare v8 platform for multi-isolate support (workers preparation) #89
Conversation
I see a bunch of NodePlatform method signatures changing. Do you think it'd make sense to keep no-isolate versions of those which just iterate over all the isolates and call the isolate versions of those methods to reduce change impact on embedders? |
@Qard I think that’s just |
src/node.cc
Outdated
@@ -259,28 +259,32 @@ static v8::Isolate* node_isolate; | |||
|
|||
node::DebugOptions debug_options; | |||
|
|||
#ifdef NODE_USE_V8_PLATFORM | |||
NodePlatform* NodePlatform::platform = nullptr; |
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.
As far as I can tell, we don't actually need to switch this to a static field. It's initialized the same way in the Initialize()
method, it's just pointing at NodePlatform::platform
rather than _platform
. It doesn't seem like NodePlatform
itself actually makes any use of that reference. Did I miss something?
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.
Updated with a new approach :)
9cd5c32
to
995afd6
Compare
@ayojs/core I’d appreciate some advice on how to make reviewing this easier – I realize this is a pretty niché topic within Node/V8… |
src/node.h
Outdated
}; | ||
|
||
// If `platform` is passed, it will be used to register new worker instances. | ||
// It can be `nullptr`, in which case creating new workers will not work. |
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.
The word "creating new workers" is vague to me. Creating new workers in the isolate for which isolate data are created? or creating new workers whose isolate is the isolate for which isolate data are created?
src/node_platform.cc
Outdated
static void FlushTasks(uv_async_t* handle) { | ||
NodePlatform* platform = static_cast<NodePlatform*>(handle->data); | ||
platform->FlushForegroundTasksInternal(); | ||
void PerIsolatePlatformData::FlushTasks(uv_async_t* handle) { |
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.
Is it possible to move this function to where all the other PerIsolatePlatformData
methods are?
src/node_platform.h
Outdated
@@ -3,13 +3,18 @@ | |||
|
|||
#include <queue> | |||
#include <vector> | |||
#include <unordered_map> |
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.
order :)
src/node.h
Outdated
@@ -209,8 +210,26 @@ NODE_EXTERN void Init(int* argc, | |||
class IsolateData; | |||
class Environment; | |||
|
|||
NODE_EXTERN IsolateData* CreateIsolateData(v8::Isolate* isolate, | |||
struct uv_loop_s* loop); | |||
class WorkerSupportingPlatform : public v8::Platform { |
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 the name be made more generic, like maybe MultiIsolatePlatform
? After all, this is a public API.
@TimothyGu @Qard Fixed review nits, please take another look if you can :) |
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. PR-URL: ayojs#89 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
f9b3f31
to
2f47b5b
Compare
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. PR-URL: ayojs/ayo#89 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. Original-PR-URL: ayojs/ayo#89 Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> PR-URL: #16700 Reviewed-By: James M Snell <jasnell@gmail.com>
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. Original-PR-URL: ayojs/ayo#89 Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> PR-URL: #16700 Reviewed-By: James M Snell <jasnell@gmail.com>
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. Original-PR-URL: ayojs/ayo#89 Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> PR-URL: nodejs#16700 Reviewed-By: James M Snell <jasnell@gmail.com>
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. Backport-PR-URL: #20901 Original-PR-URL: ayojs/ayo#89 Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> PR-URL: #16700 Reviewed-By: James M Snell <jasnell@gmail.com>
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. Backport-PR-URL: #20901 Original-PR-URL: ayojs/ayo#89 Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> PR-URL: #16700 Reviewed-By: James M Snell <jasnell@gmail.com>
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes