Skip to content

deps: V8: cherry-pick b49206d fom upstream - #20727

Closed
ofrobots wants to merge 1 commit into
nodejs:masterfrom
ofrobots:backport-v8-5338
Closed

deps: V8: cherry-pick b49206d fom upstream#20727
ofrobots wants to merge 1 commit into
nodejs:masterfrom
ofrobots:backport-v8-5338

Conversation

@ofrobots

@ofrobotsofrobots commented May 14, 2018

Copy link
Copy Markdown
Contributor

Ref: #20083

Original commit message:

ThreadDataTable: Change global linked list to per-Isolate hash map.

For use cases with a large number of threads or a large number of isolates (or
both), ThreadDataTable can be a major performance bottleneck due to O(n)
lookup time of the linked list. Switching to a hash map reduces this to O(1).

Example 1: Sandstorm.io, a Node.js app that utilizes "fibers", was observed
spending the majority of CPU time iterating over the ThreadDataTable.
See: https://sandstorm.io/news/2016-09-30-fiber-bomb-debugging-story

Example 2: Cloudflare's Workers engine, a high-multi-tenancy web server
framework built on V8 (but not Node), creates large numbers of threads and
isolates per-process. It saw a 34x improvement in throughput when we applied
this patch.

Cloudflare has been using a patch in production since the Workers launch which
replaces the linked list with a hash map -- but still global.

This commit builds on that but goes further and creates a separate hash map
and mutex for each isolate, with the table being a member of the Isolate
class. This avoids any globals and should reduce lock contention.

Bug: v8:5338
Change-Id: If0d11509afb2e043b888c376e36d3463db931b47
Reviewed-on: https://chromium-review.googlesource.com/1014407
Reviewed-by: Yang Guo yangguo@chromium.org
Commit-Queue: Yang Guo yangguo@chromium.org
Cr-Commit-Position: refs/heads/master@{#52753}

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

CI: https://ci.nodejs.org/job/node-test-pull-request/14871/
V8-CI: https://ci.nodejs.org/view/All/job/node-test-commit-v8-linux/1368/

@nodejs-github-botnodejs-github-bot added build Issues and PRs related to build files or the CI. v8 engine Issues and PRs related to the V8 dependency. labels May 14, 2018
Original commit message:
ThreadDataTable: Change global linked list to per-Isolate hash map.
For use cases with a large number of threads or a large number of isolates (or
both), ThreadDataTable can be a major performance bottleneck due to O(n)
lookup time of the linked list. Switching to a hash map reduces this to O(1).
Example 1: Sandstorm.io, a Node.js app that utilizes "fibers", was observed
spending the majority of CPU time iterating over the ThreadDataTable.
See: https://sandstorm.io/news/2016-09-30-fiber-bomb-debugging-story
Example 2: Cloudflare's Workers engine, a high-multi-tenancy web server
framework built on V8 (but not Node), creates large numbers of threads and
isolates per-process. It saw a 34x improvement in throughput when we applied
this patch.
Cloudflare has been using a patch in production since the Workers launch which
replaces the linked list with a hash map -- but still global.
This commit builds on that but goes further and creates a separate hash map
and mutex for each isolate, with the table being a member of the Isolate
class. This avoids any globals and should reduce lock contention.
Bug: v8:5338
Change-Id: If0d11509afb2e043b888c376e36d3463db931b47
Reviewed-on: https://chromium-review.googlesource.com/1014407
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{nodejs#52753}
PR-URL: nodejs#20727
Ref: nodejs#20083

@bnoordhuisbnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. New CI because the previous one bombed on infrastructure issues:

https://ci.nodejs.org/job/node-test-pull-request/14877/

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 15, 2018
@ofrobots

Copy link
Copy Markdown
ContributorAuthor

New CI was all green: https://ci.nodejs.org/job/node-test-commit/18544/. Landing.

@ofrobots

Copy link
Copy Markdown
ContributorAuthor

Landed in 0ebbd76.

@ofrobots
ofrobots deleted the backport-v8-5338 branch May 17, 2018 18:25
ofrobots added a commit that referenced this pull request May 17, 2018
Original commit message:
ThreadDataTable: Change global linked list to per-Isolate hash map.
For use cases with a large number of threads or a large number of
isolates (or both), ThreadDataTable can be a major performance
bottleneck due to O(n) lookup time of the linked list. Switching to a
hash map reduces this to O(1).
Example 1: Sandstorm.io, a Node.js app that utilizes "fibers", was
observed spending the majority of CPU time iterating over the
ThreadDataTable.
See: https://sandstorm.io/news/2016-09-30-fiber-bomb-debugging-story
Example 2: Cloudflare's Workers engine, a high-multi-tenancy web
server framework built on V8 (but not Node), creates large numbers of
threads and isolates per-process. It saw a 34x improvement in
throughput when we applied this patch.
Cloudflare has been using a patch in production since the Worker
launch which replaces the linked list with a hash map -- but still
global.
This commit builds on that but goes further and creates a separate
hash map and mutex for each isolate, with the table being a member of
the Isolate class. This avoids any globals and should reduce lock
contention.
Bug: v8:5338
Change-Id: If0d11509afb2e043b888c376e36d3463db931b47
Reviewed-on: https://chromium-review.googlesource.com/1014407
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52753}
PR-URL: #20727
Ref: #20083
Refs: #20083
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@KoenLav

Copy link
Copy Markdown

@ofrobots is there anything still needed to get this into Node.js 8?

@ofrobots

Copy link
Copy Markdown
ContributorAuthor

@KoenLav the process we follow is that a fix first has to be available on the current release line before it is considered for back-porting to LTS by the @nodejs/release team. I have attached the labels above which will make this fix show up on the list of potential back-ports to the LTS releases.

It is going to take a little while before you see it on 8 LTS – but the objective is to make sure we have adequate feedback from the current line to avoid disrupting the LTS lines.. /cc @nodejs/release in case I got anything wrong about the release process.

MylesBorins pushed a commit that referenced this pull request May 22, 2018
Original commit message:
ThreadDataTable: Change global linked list to per-Isolate hash map.
For use cases with a large number of threads or a large number of
isolates (or both), ThreadDataTable can be a major performance
bottleneck due to O(n) lookup time of the linked list. Switching to a
hash map reduces this to O(1).
Example 1: Sandstorm.io, a Node.js app that utilizes "fibers", was
observed spending the majority of CPU time iterating over the
ThreadDataTable.
See: https://sandstorm.io/news/2016-09-30-fiber-bomb-debugging-story
Example 2: Cloudflare's Workers engine, a high-multi-tenancy web
server framework built on V8 (but not Node), creates large numbers of
threads and isolates per-process. It saw a 34x improvement in
throughput when we applied this patch.
Cloudflare has been using a patch in production since the Worker
launch which replaces the linked list with a hash map -- but still
global.
This commit builds on that but goes further and creates a separate
hash map and mutex for each isolate, with the table being a member of
the Isolate class. This avoids any globals and should reduce lock
contention.
Bug: v8:5338
Change-Id: If0d11509afb2e043b888c376e36d3463db931b47
Reviewed-on: https://chromium-review.googlesource.com/1014407
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52753}
PR-URL: #20727
Ref: #20083
Refs: #20083
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleaxaddaleax mentioned this pull request May 22, 2018
@veered

Copy link
Copy Markdown

@ofrobots Any idea on when this might land in Node 8? It'll be a huge deal for the Meteor community :)

@ofrobots

Copy link
Copy Markdown
ContributorAuthor

@MylesBorins is this on track for a 8.x release?

@MylesBorins

Copy link
Copy Markdown
Contributor

@ofrobots this is going to need a manual backport to 8.x

ping @nodejs/v8-update

@ofrobots

Copy link
Copy Markdown
ContributorAuthor

8.x backport: #21529

ofrobots added a commit to ofrobots/node that referenced this pull request Jun 28, 2018
This is the v8.x backport of nodejs#20727.
Original commit message:
ThreadDataTable: Change global linked list to per-Isolate hash map.
For use cases with a large number of threads or a large number of
isolates (or both), ThreadDataTable can be a major performance
bottleneck due to O(n) lookup time of the linked list. Switching to a
hash map reduces this to O(1).
Example 1: Sandstorm.io, a Node.js app that utilizes "fibers", was
observed spending the majority of CPU time iterating over the
ThreadDataTable.
See: https://sandstorm.io/news/2016-09-30-fiber-bomb-debugging-story
Example 2: Cloudflare's Workers engine, a high-multi-tenancy web
server framework built on V8 (but not Node), creates large numbers of
threads and isolates per-process. It saw a 34x improvement in
throughput when we applied this patch.
Cloudflare has been using a patch in production since the Worker
launch which replaces the linked list with a hash map -- but still
global.
This commit builds on that but goes further and creates a separate
hash map and mutex for each isolate, with the table being a member of
the Isolate class. This avoids any globals and should reduce lock
contention.
Bug: v8:5338
Change-Id: If0d11509afb2e043b888c376e36d3463db931b47
Reviewed-on: https://chromium-review.googlesource.com/1014407
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{nodejs#52753}
Backport-PR-URL: nodejs#21529
PR-URL: nodejs#20727
Refs: nodejs#20083
Refs: nodejs#20083
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request Jul 9, 2018
rvagg pushed a commit that referenced this pull request Aug 16, 2018
This is the v8.x backport of #20727.
Original commit message:
ThreadDataTable: Change global linked list to per-Isolate hash map.
For use cases with a large number of threads or a large number of
isolates (or both), ThreadDataTable can be a major performance
bottleneck due to O(n) lookup time of the linked list. Switching to a
hash map reduces this to O(1).
Example 1: Sandstorm.io, a Node.js app that utilizes "fibers", was
observed spending the majority of CPU time iterating over the
ThreadDataTable.
See: https://sandstorm.io/news/2016-09-30-fiber-bomb-debugging-story
Example 2: Cloudflare's Workers engine, a high-multi-tenancy web
server framework built on V8 (but not Node), creates large numbers of
threads and isolates per-process. It saw a 34x improvement in
throughput when we applied this patch.
Cloudflare has been using a patch in production since the Worker
launch which replaces the linked list with a hash map -- but still
global.
This commit builds on that but goes further and creates a separate
hash map and mutex for each isolate, with the table being a member of
the Isolate class. This avoids any globals and should reduce lock
contention.
Bug: v8:5338
Change-Id: If0d11509afb2e043b888c376e36d3463db931b47
Reviewed-on: https://chromium-review.googlesource.com/1014407
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52753}
Backport-PR-URL: #21529
PR-URL: #20727
Refs: #20083
Refs: #20083
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.buildIssues and PRs related to build files or the CI.v8 engineIssues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@ofrobots@KoenLav@veered@MylesBorins@bnoordhuis@jasnell@targos@richardlau@BridgeAR@nodejs-github-bot