Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Issue 2726593002: Use mayNotBeMainThread() for wrapper optimization (Closed)

Created:
3 years, 9 months ago by adithyas
Modified:
3 years, 9 months ago
Reviewers:
haraken, jbroman, Yuki
CC:
blink-reviews, blink-reviews-bindings_chromium.org, blink-reviews-dom_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, rwlbuis, sof
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Use mayNotBeMainThread for wrapper optimization DOMDataStore has overloaded methods (for Node*) that checks if we're in a main world by checking if isolated worlds exist, and returns a main world wrapper directly if they don't exist. Node is used because it can never be created in a worker world. This patch changes the main world check to checking if we're on the main thread (using mayNotBeMainThread) and if any non-main worlds have been created on the main thread (If there are no non-main worlds, we have to be in the main world). This way, we don't need Node. BUG=682322 Review-Url: https://codereview.chromium.org/2726593002 Cr-Commit-Position: refs/heads/master@{#455530} Committed: https://chromium.googlesource.com/chromium/src/+/199953cd647ec50f5f07d9025e5a8ba6948f8079

Patch Set 1 #

Total comments: 1

Patch Set 2 : Use thread safe counter #

Total comments: 1

Patch Set 3 : Use boolean that is set in main thread #

Patch Set 4 : Minor changes #

Total comments: 4

Patch Set 5 : Use mayNotBeMainThread to do fast path check #

Patch Set 6 : Rebase, fix tests #

Total comments: 6

Patch Set 7 : Renaming + move decrement to destructor #

Total comments: 6

Patch Set 8 : Use V8TestingScope #

Unified diffs Side-by-side diffs Delta from patch set Stats (+46 lines, -137 lines) Patch
M third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h View 1 2 3 4 5 6 5 chunks +13 lines, -52 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h View 1 2 3 4 5 6 7 2 chunks +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp View 1 2 3 4 5 6 7 7 chunks +7 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ToV8.h View 1 2 3 4 1 chunk +1 line, -9 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/V8Binding.h View 1 2 3 4 5 6 7 2 chunks +3 lines, -19 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/V8DOMWrapper.h View 3 chunks +0 lines, -21 lines 0 comments Download
M third_party/WebKit/Source/core/dom/DocumentTest.cpp View 1 2 3 4 5 6 7 3 chunks +3 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/Node.h View 1 2 3 4 5 6 7 1 chunk +0 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Node.cpp View 1 2 3 4 5 6 7 1 chunk +0 lines, -21 lines 0 comments Download
M third_party/WebKit/Source/core/dom/RangeTest.cpp View 1 2 3 4 5 6 7 3 chunks +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/StaticRangeTest.cpp View 1 2 3 4 5 6 7 4 chunks +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp View 1 2 3 4 5 6 7 3 chunks +6 lines, -1 line 0 comments Download

Messages

Total messages: 37 (19 generated)
jbroman
https://codereview.chromium.org/2726593002/diff/1/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp File third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp (right): https://codereview.chromium.org/2726593002/diff/1/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp#newcode98 third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp:98: workerWorldCreated = true; This is accessed on multiple threads. ...
3 years, 9 months ago (2017-02-28 18:50:18 UTC) #2
haraken
https://codereview.chromium.org/2726593002/diff/20001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h File third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h (right): https://codereview.chromium.org/2726593002/diff/20001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h#newcode72 third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h:72: static bool isolatedWorldsOrWorkerWorldExist() { This check needs to be ...
3 years, 9 months ago (2017-03-01 01:19:24 UTC) #7
jbroman
On 2017/03/01 at 01:19:24, haraken wrote: > https://codereview.chromium.org/2726593002/diff/20001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h > File third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h (right): > > https://codereview.chromium.org/2726593002/diff/20001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h#newcode72 ...
3 years, 9 months ago (2017-03-01 03:04:56 UTC) #8
adithyas
On 2017/03/01 at 03:04:56, jbroman wrote: > On 2017/03/01 at 01:19:24, haraken wrote: > > ...
3 years, 9 months ago (2017-03-01 20:07:10 UTC) #9
jbroman
https://codereview.chromium.org/2726593002/diff/60001/third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h File third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h (right): https://codereview.chromium.org/2726593002/diff/60001/third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h#newcode156 third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h:156: static bool canUseScriptWrappable() { TBH I now find this ...
3 years, 9 months ago (2017-03-01 20:41:07 UTC) #10
adithyas
https://codereview.chromium.org/2726593002/diff/60001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2726593002/diff/60001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode117 third_party/WebKit/Source/core/workers/WorkerThread.cpp:117: DOMWrapperWorld::isolatedOrWorkerWorldCreated(); On 2017/03/01 at 20:41:07, jbroman wrote: > I ...
3 years, 9 months ago (2017-03-01 23:56:51 UTC) #11
haraken
On 2017/03/01 23:56:51, adithyas wrote: > https://codereview.chromium.org/2726593002/diff/60001/third_party/WebKit/Source/core/workers/WorkerThread.cpp > File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): > > https://codereview.chromium.org/2726593002/diff/60001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode117 > ...
3 years, 9 months ago (2017-03-02 01:02:39 UTC) #12
adithyas
I've updated the patch to use WTF::mayNotBeMainThread() to do a fast check for if we're ...
3 years, 9 months ago (2017-03-07 21:00:58 UTC) #22
jbroman
+yukishiino, who you talked to about Text::splitText lgtm with nits I'm not thrilled about the ...
3 years, 9 months ago (2017-03-07 22:15:51 UTC) #24
adithyas
https://codereview.chromium.org/2726593002/diff/100001/third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h File third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h (right): https://codereview.chromium.org/2726593002/diff/100001/third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h#newcode157 third_party/WebKit/Source/bindings/core/v8/DOMDataStore.h:157: static bool canUseScriptWrappable() { On 2017/03/07 at 22:15:51, jbroman ...
3 years, 9 months ago (2017-03-07 22:58:36 UTC) #25
Yuki
LGTM. Could you use V8TestingScope instead of explicitly instantiating a ScriptState? https://codereview.chromium.org/2726593002/diff/120001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp File third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp (right): ...
3 years, 9 months ago (2017-03-08 09:22:04 UTC) #26
haraken
LGTM https://codereview.chromium.org/2726593002/diff/120001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp File third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp (right): https://codereview.chromium.org/2726593002/diff/120001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp#newcode84 third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp:84: unsigned DOMWrapperWorld::numberOfNonMainWorldsInMainThread = 0; s_numberOfNonMainWorldsInMainThread https://codereview.chromium.org/2726593002/diff/120001/third_party/WebKit/Source/core/dom/RangeTest.cpp File third_party/WebKit/Source/core/dom/RangeTest.cpp ...
3 years, 9 months ago (2017-03-08 09:25:25 UTC) #27
adithyas
https://codereview.chromium.org/2726593002/diff/120001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp File third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp (right): https://codereview.chromium.org/2726593002/diff/120001/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp#newcode84 third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp:84: unsigned DOMWrapperWorld::numberOfNonMainWorldsInMainThread = 0; On 2017/03/08 at 09:25:24, haraken ...
3 years, 9 months ago (2017-03-08 18:20:10 UTC) #28
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2726593002/140001
3 years, 9 months ago (2017-03-08 18:21:24 UTC) #31
commit-bot: I haz the power
Committed patchset #8 (id:140001) as https://chromium.googlesource.com/chromium/src/+/199953cd647ec50f5f07d9025e5a8ba6948f8079
3 years, 9 months ago (2017-03-08 20:29:32 UTC) #34
esprehn
I'm curious, does this patch mean that now all extension content scripts put all the ...
3 years, 9 months ago (2017-03-24 20:38:31 UTC) #35
esprehn
On 2017/03/24 at 20:38:31, esprehn wrote: > I'm curious, does this patch mean that now ...
3 years, 9 months ago (2017-03-24 21:46:26 UTC) #36
haraken
3 years, 9 months ago (2017-03-27 04:36:20 UTC) #37
Message was sent while issue was closed.
On 2017/03/24 21:46:26, esprehn wrote:
> On 2017/03/24 at 20:38:31, esprehn wrote:
> > I'm curious, does this patch mean that now all extension content scripts put
> all the Node wrapper machinery into slow mode? That seems somewhat concerning.
> Most users have at least one extension installed, ex. every googler as
> PasswordAlert.
> > 
> > I don't think we want to be using the non-main-world count like this since
it
> makes content scripts degrade the page performance (actually worse, since this
> is static, so a content script in one tab can degrade perf for all other tabs
in
> the entire process).
> 
> Oh I see we already had all this before with canUseScriptWrappable(), hmm, we
> should probably think about what we might do to avoid this cliff where
> installing an extension makes your bindings slower.

canUseMainWorldWrapper() is the fastest way to check if we're in the main world.
This check works only when there's no isolated world. We introduced the check
just to game Dromaeo.

holderContainsWrapper() is the second fastest way to check if we're in the main
world. I think we'll hit this path in common real-world cases.

Powered by Google App Engine
This is Rietveld 408576698