[v8.x] backport some V8 platform changes#20901
Closed
addaleax wants to merge 4 commits intonodejs:v8.x-stagingfrom
Closed
[v8.x] backport some V8 platform changes#20901addaleax wants to merge 4 commits intonodejs:v8.x-stagingfrom
addaleax wants to merge 4 commits intonodejs:v8.x-stagingfrom
Conversation
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 <[email protected]> PR-URL: nodejs#16700 Reviewed-By: James M Snell <[email protected]>
Worker threads need an event loop without active libuv handles in order to shut down. One source of handles that was previously not accounted for were delayed V8 tasks; these create timers that would be standing in the way of clearing the event loop. To solve this, keep track of the scheduled tasks in a list and close their timer handles before the corresponding isolate/loop is removed from the platform. It is not clear from the V8 documentation what the expectation is with respect to pending background tasks at the end of the isolate lifetime; however, an alternative approach of executing these scheduled tasks when flushing them led to an infinite loop of tasks scheduling each other; so it seems safe to assume that the behaviour implemented in this patch is at least acceptable. Original-PR-URL: ayojs/ayo#120 Original-Reviewed-By: Stephen Belanger <[email protected]> PR-URL: nodejs#16700 Reviewed-By: James M Snell <[email protected]>
Replace raw pointers in task queues with std::unique_ptr. This makes ownership obvious. PR-URL: nodejs#16970 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Use std::unique_ptr for delayed tasks in the scheduled delayed tasks vector. This makes it clear that the vector has ownership of the delayed tasks and is responsible for deleting them. Use a custom deleter for the pointers because libuv needs to close the handle and then delete the data. Provide the handle when creating the pointer instead of invoking the special delete action everytime an element is removed from the vector. PR-URL: nodejs#17083 Reviewed-By: Anna Henningsen <[email protected]>
2 tasks
TimothyGu
approved these changes
May 23, 2018
danbev
approved these changes
May 23, 2018
| flush_tasks_.data = static_cast<void*>(this); | ||
| uv_unref(reinterpret_cast<uv_handle_t*>(&flush_tasks_)); | ||
| PerIsolatePlatformData::PerIsolatePlatformData( | ||
| v8::Isolate* isolate, uv_loop_t* loop) |
Contributor
There was a problem hiding this comment.
Nit: Perhaps use an unqualified name for the Isolate type here?
Contributor
There was a problem hiding this comment.
Since this is a backport is it safe to assume this is what already landed upstream
Member
Author
There was a problem hiding this comment.
Yeah, I’d prefer to avoid stylistic changes outside of master :)
Contributor
|
Could you also include #17133? |
Member
Author
|
@MylesBorins Already included that as part of the backporting process (in order to make Or are you seeing errors because of that? |
Contributor
|
@addaleax didn't know it was included because not documented. Was just going through the backlog 😄 |
Contributor
|
landed in 35055a1...beb45ac |
084ef60 to
859dc64
Compare
MylesBorins
pushed a commit
that referenced
this pull request
Jun 14, 2018
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 <[email protected]> PR-URL: #16700 Reviewed-By: James M Snell <[email protected]>
MylesBorins
pushed a commit
that referenced
this pull request
Jun 14, 2018
Worker threads need an event loop without active libuv handles in order to shut down. One source of handles that was previously not accounted for were delayed V8 tasks; these create timers that would be standing in the way of clearing the event loop. To solve this, keep track of the scheduled tasks in a list and close their timer handles before the corresponding isolate/loop is removed from the platform. It is not clear from the V8 documentation what the expectation is with respect to pending background tasks at the end of the isolate lifetime; however, an alternative approach of executing these scheduled tasks when flushing them led to an infinite loop of tasks scheduling each other; so it seems safe to assume that the behaviour implemented in this patch is at least acceptable. Backport-PR-URL: #20901 Original-PR-URL: ayojs/ayo#120 Original-Reviewed-By: Stephen Belanger <[email protected]> PR-URL: #16700 Reviewed-By: James M Snell <[email protected]>
MylesBorins
pushed a commit
that referenced
this pull request
Jun 14, 2018
Replace raw pointers in task queues with std::unique_ptr. This makes ownership obvious. Backport-PR-URL: #20901 PR-URL: #16970 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
MylesBorins
pushed a commit
that referenced
this pull request
Jun 14, 2018
Use std::unique_ptr for delayed tasks in the scheduled delayed tasks vector. This makes it clear that the vector has ownership of the delayed tasks and is responsible for deleting them. Use a custom deleter for the pointers because libuv needs to close the handle and then delete the data. Provide the handle when creating the pointer instead of invoking the special delete action everytime an element is removed from the vector. Backport-PR-URL: #20901 PR-URL: #17083 Reviewed-By: Anna Henningsen <[email protected]>
rvagg
pushed a commit
that referenced
this pull request
Aug 16, 2018
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 <[email protected]> PR-URL: #16700 Reviewed-By: James M Snell <[email protected]>
rvagg
pushed a commit
that referenced
this pull request
Aug 16, 2018
Worker threads need an event loop without active libuv handles in order to shut down. One source of handles that was previously not accounted for were delayed V8 tasks; these create timers that would be standing in the way of clearing the event loop. To solve this, keep track of the scheduled tasks in a list and close their timer handles before the corresponding isolate/loop is removed from the platform. It is not clear from the V8 documentation what the expectation is with respect to pending background tasks at the end of the isolate lifetime; however, an alternative approach of executing these scheduled tasks when flushing them led to an infinite loop of tasks scheduling each other; so it seems safe to assume that the behaviour implemented in this patch is at least acceptable. Backport-PR-URL: #20901 Original-PR-URL: ayojs/ayo#120 Original-Reviewed-By: Stephen Belanger <[email protected]> PR-URL: #16700 Reviewed-By: James M Snell <[email protected]>
rvagg
pushed a commit
that referenced
this pull request
Aug 16, 2018
Replace raw pointers in task queues with std::unique_ptr. This makes ownership obvious. Backport-PR-URL: #20901 PR-URL: #16970 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
rvagg
pushed a commit
that referenced
this pull request
Aug 16, 2018
Use std::unique_ptr for delayed tasks in the scheduled delayed tasks vector. This makes it clear that the vector has ownership of the delayed tasks and is responsible for deleting them. Use a custom deleter for the pointers because libuv needs to close the handle and then delete the data. Provide the handle when creating the pointer instead of invoking the special delete action everytime an element is removed from the vector. Backport-PR-URL: #20901 PR-URL: #17083 Reviewed-By: Anna Henningsen <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport #16700 + #16970 + #17083 (the latter two depend on the first one)