-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: Node implementation of v8::Platform #14001
Conversation
/cc @jeisinger @nodejs/v8 |
v8/v8@3d8e87a was reverted upstream in V8 due to tsan failures in multi-isolate scenarios. It should be safe for use by Node.js but we can also swap out that commit once it re-lands in V8 before landing this PR. (edit by @addaleax: turned the git commit ref into a v8/v8@… ref) |
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.
Commented with a few style nits but I think that’s it.
src/node_platform.cc
Outdated
void NodePlatform::CallOnBackgroundThread(Task* task, | ||
ExpectedRuntime expected_runtime) { | ||
uv_work_t* req = new uv_work_t; | ||
req->data = reinterpret_cast<void*>(task); |
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.
static_cast
?
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.
Done.
src/node_platform.cc
Outdated
double delay_in_seconds) { | ||
double delay_millis = delay_in_seconds * 1000; | ||
uv_timer_t* schedule_req = new uv_timer_t; | ||
schedule_req->data = reinterpret_cast<void*>(task); |
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.
static_cast
?
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.
Done.
src/node_platform.cc
Outdated
return static_cast<size_t>(threads_); | ||
} | ||
|
||
void RunBackgroundTask(uv_work_t *req) { |
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.
tiny style nit: uv_work_t* req
(like below)
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.
Done.
src/node_platform.cc
Outdated
} | ||
|
||
void RunForegroundTask(uv_timer_t* req) { | ||
Task* task = reinterpret_cast<Task*>(req->data); |
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.
static_cast
here and in the one above as well. ;)
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.
Done.
*/ | ||
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform( | ||
int thread_pool_size = 0, | ||
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled); | ||
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled, | ||
v8::TracingController* tracing_controller = 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.
FYI, conflicts with #13985.
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.
That has landed and this PR has been rebased.
src/node.cc
Outdated
tracing::Agent* tracing_agent_; | ||
NodePlatform* platform_; | ||
#else // !NODE_USE_V8_PLATFORM | ||
void Initialize(int thread_pool_size) {} |
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.
This needs to be updated to the new prototype.
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.
Done.
src/node.cc
Outdated
void PumpMessageLoop(Isolate* isolate) { | ||
v8::platform::PumpMessageLoop(platform_, isolate); | ||
tracing::TraceEventHelper::SetTracingController( | ||
trace_enabled ? tracing_agent_->GetTracingController() : 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.
4 space indent.
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.
@bnoordhuis Is there a guideline anywhere for C++ code indentation? I (and others possibly) am usually fairly uncertain where the 4-space rule should apply, and where 2-space.
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.
I’m not sure we’ve written it done somewhere, but generally, use 4 spaces if it’s a statement continuation, 2 spaces if it’s indentation for a block/loop body/conditional statement body/etc.
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.
I've updated to 4 spaces.
src/node.cc
Outdated
void Initialize(int thread_pool_size, uv_loop_t* loop) { | ||
tracing_agent_ = | ||
trace_enabled ? new tracing::Agent() : nullptr; | ||
platform_ = new NodePlatform(thread_pool_size, loop, |
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.
These are never freed?
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.
They are now freed in Dispose
.
src/node_platform.cc
Outdated
delete req; | ||
} | ||
|
||
void RunForegroundTask(uv_timer_t* req) { |
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.
s/req/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.
Done throughout.
src/node_platform.cc
Outdated
|
||
double NodePlatform::MonotonicallyIncreasingTime() { | ||
// Convert nanos to seconds | ||
return uv_hrtime() / 1000000000.0; |
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.
1e9
is a little easier to parse for humans. Can you punctuate the comment?
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.
Done.
src/node_platform.h
Outdated
|
||
using v8::Isolate; | ||
using v8::Platform; | ||
using v8::Task; |
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 you move these to the .cc file and use fully qualified names here? Rule of thumb: no using declarations in headers.
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.
Fixed.
src/node_platform.h
Outdated
v8::TracingController* GetTracingController() override; | ||
|
||
private: | ||
int threads_; |
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 you call this e.g. num_threads_
?
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.
Done.
src/node_platform.cc
Outdated
return static_cast<size_t>(threads_); | ||
} | ||
|
||
void RunBackgroundTask(uv_work_t *req) { |
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.
Maybe these internal functions could be made static
or part of an anonymous namespace?
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.
Good point – they might be best written as lambdas, for readability?
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.
I found that with lambdas there were too many variables named handle
. I've made them static
for now. I can switch to lambdas if that is preferred.
src/node_platform.h
Outdated
#include "node_mutex.h" | ||
#include "uv.h" | ||
|
||
#include <queue> |
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.
Are node_mutex.h
and queue
actually used anywhere within the file?
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.
Removed.
Thanks for the comments! I'm currently looking into some intermittent crashes in GC brought on by this change. I'll address these comments once I figure that out. |
src/node_platform.h
Outdated
size_t NumberOfAvailableBackgroundThreads() override; | ||
void CallOnBackgroundThread(Task* task, | ||
ExpectedRuntime expected_runtime) override; | ||
void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override; |
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.
Should this just be Isolate* or should the others be v8::Isolate*
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.
These should all be v8::Isolate
.
src/node_platform.h
Outdated
class NodePlatform : public Platform { | ||
public: | ||
NodePlatform(int thread_pool_size, uv_loop_t* loop, | ||
v8::TracingController* tracing_controller); |
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.
Would be nice if the API for NodePlatform did not depend on v8 specific types like v8::TracingController and v8::Isolate (below) but it is still a good start just be abstracting NodePlatform itself.
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.
This was discussed briefly in #12980. This is not an attempt to define a general VM interface. The only goal is to provide a new implementation of v8::Platform
as the default platform which is currently used by Node will may allow the process to exit during wasm module compilation.
src/node_platform.cc
Outdated
Task* task = static_cast<Task*>(handle->data); | ||
task->Run(); | ||
delete task; | ||
delete 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.
ASAN complains about this line, it looks like uv_run() tries to delete this handle as well.
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.
This needs to call uv_close()
and not free the memory until the close callback is called.
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.
Ok, does the same logic apply to the uv_work_t
in AfterBackgroundTask
?
src/node.cc
Outdated
tracing_agent_ = | ||
trace_enabled ? new tracing::Agent() : nullptr; | ||
platform_ = new NodePlatform(thread_pool_size, loop, | ||
trace_enabled ? tracing_agent_->GetTracingController() : 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.
Style nit: four space indent.
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.
Fixed.
src/node.cc
Outdated
} | ||
|
||
void Dispose() { | ||
delete platform_; | ||
platform_ = nullptr; | ||
delete tracing_agent_; |
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 you set tracing_agent_ = 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.
Done.
src/node_platform.cc
Outdated
Task* task = static_cast<Task*>(handle->data); | ||
task->Run(); | ||
delete task; | ||
delete 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.
This needs to call uv_close()
and not free the memory until the close callback is called.
src/node_platform.cc
Outdated
|
||
void NodePlatform::CallOnBackgroundThread(Task* task, | ||
ExpectedRuntime expected_runtime) { | ||
uv_work_t* handle = new uv_work_t; |
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 you call new uv_work_t()
here? Coverity tends to complain about heap-allocating structures without initializing them. Same a few lines below with the new uv_timer_t
call.
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.
Done.
src/node_platform.cc
Outdated
uv_timer_t* handle = new uv_timer_t; | ||
handle->data = static_cast<void*>(task); | ||
uv_timer_init(loop_, handle); | ||
// Timers may not guarentee queue ordering of events with the same delay if |
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.
Typo: guarantee
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.
Done.
src/node_platform.h
Outdated
|
||
private: | ||
int num_threads_; | ||
uv_loop_t* loop_; |
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.
Maybe make these const since they'll never change.
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.
I've made the thread count const. uv_timer_init
and uv_queue_work
don't like const loops.
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.
I mean uv_loop_t* const loop
, i.e., non-reseatable pointer. Not a big thing though.
src/tracing/trace_event.cc
Outdated
@@ -3,14 +3,14 @@ | |||
namespace node { | |||
namespace tracing { | |||
|
|||
v8::Platform* platform_ = nullptr; | |||
v8::TracingController* controller_ = 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.
Since you're here: g_controller
? We use underscore suffix convention really only for data members.
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.
Done.
Trying the CI: https://ci.nodejs.org/job/node-test-pull-request/9287/ |
The CI looks mostly green. The repl timeout seems unrelated. The One option would be to drop all V8 background tasks queued during the execution of |
some background tasks from the GC will count down semaphores while the main thread waits for the semaphore, so not running background tasks will result in a deadlock on the main thread. |
If background tasks are allowed to be queue during the |
Flushing all background tasks after |
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.
Just reaffirming that this still LGTM
For an update on this, I worked with the V8 team to stop the main thread from blocking on background task completion (reflected in the most recent 3 backports on the PR). A more desirable fix would be to let background tasks started inside The current solution will only be problematic if V8 background tasks started inside I've started a fresh CI here: https://ci.nodejs.org/job/node-test-pull-request/9486/ |
It looks like there is one remaining related failure which is on windows: https://ci.nodejs.org/job/node-test-binary-windows/10290/RUN_SUBSET=1,VS_VERSION=vs2017,label=win2016/tapResults/. I can try to get my hands on a windows machine but if anyone on @nodejs/platform-windows can reproduce this or has thoughts on why libuv is unhappy I'd appreciate the help. |
After a few more fixes, it looks like |
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.
src/* LGTM
Original commit message: [heap] Move SweeperTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6655 Change-Id: Icdaae744ee73146b86b9a28c8035138746721971 Reviewed-on: https://chromium-review.googlesource.com/595467 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#47036} PR-URL: nodejs#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: Make CancelableTask ids unique They were only limited to 32 bit when using the internal Hashmap. Since this has changed alreay some time ago, we can switch to 64 bit ids and check that we never overflow. Bug: Change-Id: Ia6c6d02d6b5e555c6941185a79427dc4aa2a1d62 Reviewed-on: https://chromium-review.googlesource.com/598229 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#47085} PR-URL: nodejs#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move UnmapFreeMemoryTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6671 Change-Id: I741d4b7594e8d62721dad32cbfb19551ffacd0c3 Reviewed-on: https://chromium-review.googlesource.com/599528 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#47126} PR-URL: nodejs#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
if (uv_run(env.event_loop(), UV_RUN_NOWAIT) != 0) | ||
more = true; | ||
} | ||
uv_run(env.event_loop(), UV_RUN_DEFAULT); |
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 everyone here sure this doesn't break something edge-casey with beforeExit and order of operations?
I'm trying to dig into it but have pretty much run out of time this week.
It seems to me that in some case(s) before, uv callbacks may have been called twice before the next beforeExit
, which could alter things at the very least like an addon that uses a uv_check_t
handle?
I'm assuming that this is not applicable to the 6.x branch. Please let me know if I am mistaken /cc @nodejs/v8 @nodejs/tsc |
Original commit message: [heap] Move SweeperTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6655 Change-Id: Icdaae744ee73146b86b9a28c8035138746721971 Reviewed-on: https://chromium-review.googlesource.com/595467 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#47036} PR-URL: nodejs#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: Make CancelableTask ids unique They were only limited to 32 bit when using the internal Hashmap. Since this has changed alreay some time ago, we can switch to 64 bit ids and check that we never overflow. Bug: Change-Id: Ia6c6d02d6b5e555c6941185a79427dc4aa2a1d62 Reviewed-on: https://chromium-review.googlesource.com/598229 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#47085} PR-URL: nodejs#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move UnmapFreeMemoryTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6671 Change-Id: I741d4b7594e8d62721dad32cbfb19551ffacd0c3 Reviewed-on: https://chromium-review.googlesource.com/599528 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#47126} PR-URL: nodejs#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
V8 modified the platform API to accept a tracing controller at platform creation time that is required to be present for the lifetime of the platform if tracing will every be enabled. This will simplify the implementation of a v8::Platform subclass for node. PR-URL: nodejs/node#14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move SweeperTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6655 Change-Id: Icdaae744ee73146b86b9a28c8035138746721971 Reviewed-on: https://chromium-review.googlesource.com/595467 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47036} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: Make CancelableTask ids unique They were only limited to 32 bit when using the internal Hashmap. Since this has changed alreay some time ago, we can switch to 64 bit ids and check that we never overflow. Bug: Change-Id: Ia6c6d02d6b5e555c6941185a79427dc4aa2a1d62 Reviewed-on: https://chromium-review.googlesource.com/598229 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47085} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move UnmapFreeMemoryTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6671 Change-Id: I741d4b7594e8d62721dad32cbfb19551ffacd0c3 Reviewed-on: https://chromium-review.googlesource.com/599528 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47126} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move SweeperTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6655 Change-Id: Icdaae744ee73146b86b9a28c8035138746721971 Reviewed-on: https://chromium-review.googlesource.com/595467 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47036} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: Make CancelableTask ids unique They were only limited to 32 bit when using the internal Hashmap. Since this has changed alreay some time ago, we can switch to 64 bit ids and check that we never overflow. Bug: Change-Id: Ia6c6d02d6b5e555c6941185a79427dc4aa2a1d62 Reviewed-on: https://chromium-review.googlesource.com/598229 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47085} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move UnmapFreeMemoryTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6671 Change-Id: I741d4b7594e8d62721dad32cbfb19551ffacd0c3 Reviewed-on: https://chromium-review.googlesource.com/599528 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47126} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move SweeperTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6655 Change-Id: Icdaae744ee73146b86b9a28c8035138746721971 Reviewed-on: https://chromium-review.googlesource.com/595467 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47036} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: Make CancelableTask ids unique They were only limited to 32 bit when using the internal Hashmap. Since this has changed alreay some time ago, we can switch to 64 bit ids and check that we never overflow. Bug: Change-Id: Ia6c6d02d6b5e555c6941185a79427dc4aa2a1d62 Reviewed-on: https://chromium-review.googlesource.com/598229 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47085} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Original commit message: [heap] Move UnmapFreeMemoryTask to CancelableTask This mitigates the problem of blocking on the main thread when the platform is unable to execute background tasks in a timely manner. Bug: v8:6671 Change-Id: I741d4b7594e8d62721dad32cbfb19551ffacd0c3 Reviewed-on: https://chromium-review.googlesource.com/599528 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#47126} Backport-PR-URL: #15393 PR-URL: #14001 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Node.js currently uses the V8 implementation of the DefaultPlatform
which schedules VM tasks on a V8 managed thread pool. Since the Node.js
event loop is not aware of these tasks, the Node.js process may exit
while there are outstanding VM tasks. This will become problematic once
asynchronous wasm compilation lands in V8.
This PR introduces a Node.js specific implementation of the v8::Platform
on top of libuv so that the event loop is aware of outstanding VM tasks.
Fixes: #12980
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src, tracing