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

Issue 2555013004: UserGestureIndicator: remove many unnecessary calls to isMainThread (Closed)

Created:
4 years ago by Charlie Harrison
Modified:
4 years ago
CC:
chromium-reviews, blink-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

UserGestureIndicator: remove many unnecessary calls to isMainThread Most code that calls the UserGestureIndicator knows which thread it is executing in. Calling isMainThread involves doing a thread id syscall which can be quite slow, and there are places in the loading code that do this in a tight loop (e.g. preloading resources). This patch adds an optional argument to the indicator's static methods which optionally allow callers to get the gesture state in a thread-safe way. BUG=348655 Committed: https://crrev.com/8bcf27f192944e2eea90a846156a770d4ca939fc Cr-Commit-Position: refs/heads/master@{#437941}

Patch Set 1 #

Patch Set 2 : just target processingUserGesture() #

Patch Set 3 : ASSERT -> DCHECK #

Patch Set 4 : DCHECK -> CHECK for rel bots #

Patch Set 5 : domtimer #

Patch Set 6 : [test] remove isMainThread() check in currentToken() #

Patch Set 7 : [test] remove isMainThread() check in currentToken() #

Patch Set 8 : [test] remove isMainThread() check in currentToken() #

Total comments: 6

Patch Set 9 : kinuko review #

Patch Set 10 : remove bad comment (trybots prev) #

Total comments: 6

Patch Set 11 : Add comment #

Total comments: 2

Patch Set 12 : Avoid duplicate thread checks in DOMTimer #

Unified diffs Side-by-side diffs Delta from patch set Stats (+46 lines, -17 lines) Patch
M extensions/renderer/request_sender.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/frame/DOMTimer.cpp View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +5 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/permissions/Permissions.cpp View 1 2 3 4 5 6 7 8 9 10 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/UserGestureIndicator.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +8 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/UserGestureIndicator.cpp View 1 2 3 4 5 6 7 8 3 chunks +15 lines, -9 lines 0 comments Download
M third_party/WebKit/Source/web/WebUserGestureIndicator.cpp View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -2 lines 0 comments Download
M third_party/WebKit/public/web/WebUserGestureIndicator.h View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -1 line 0 comments Download

Messages

Total messages: 60 (40 generated)
Charlie Harrison
kinuko: WDYT about this patch? I mostly relied on test coverage to find places where ...
4 years ago (2016-12-08 14:04:27 UTC) #29
Charlie Harrison
I'll add that this patch is a draft and I'm looking for a high level ...
4 years ago (2016-12-08 14:06:34 UTC) #30
kinuko
Is getting thread id still slow? I think it's related to the same issue as ...
4 years ago (2016-12-09 03:06:56 UTC) #31
kinuko
If it's making the code actually slow I think this change makes sense. In blink ...
4 years ago (2016-12-09 03:15:52 UTC) #32
Charlie Harrison
On 2016/12/09 03:06:56, kinuko wrote: > Is getting thread id still slow? I think it's ...
4 years ago (2016-12-09 03:55:44 UTC) #33
Charlie Harrison
Thanks for the review! https://codereview.chromium.org/2555013004/diff/140001/third_party/WebKit/Source/platform/UserGestureIndicator.h File third_party/WebKit/Source/platform/UserGestureIndicator.h (right): https://codereview.chromium.org/2555013004/diff/140001/third_party/WebKit/Source/platform/UserGestureIndicator.h#newcode106 third_party/WebKit/Source/platform/UserGestureIndicator.h:106: static bool processingUserGesture(ThreadCheck = DoNotCheckThreadState); ...
4 years ago (2016-12-09 15:24:14 UTC) #36
kinuko
Btw is the callsite in the RenderFrameImpl::willSendRequest() the one you're trying to optimize?
4 years ago (2016-12-12 04:30:20 UTC) #37
kinuko
https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h File third_party/WebKit/Source/platform/UserGestureIndicator.h (right): https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h#newcode118 third_party/WebKit/Source/platform/UserGestureIndicator.h:118: static bool consumeUserGestureThreadSafe(); We don't need this and currentTokenThreadSafe ...
4 years ago (2016-12-12 04:45:13 UTC) #38
Charlie Harrison
Yeah the call in willSendRequest is my biggest worry. I haven't audited all callsites but ...
4 years ago (2016-12-12 13:10:09 UTC) #39
kinuko
lgtm https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h File third_party/WebKit/Source/platform/UserGestureIndicator.h (right): https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h#newcode98 third_party/WebKit/Source/platform/UserGestureIndicator.h:98: // non-suffixed counterparts *must* be called on the ...
4 years ago (2016-12-12 14:51:26 UTC) #40
Charlie Harrison
https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h File third_party/WebKit/Source/platform/UserGestureIndicator.h (right): https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h#newcode98 third_party/WebKit/Source/platform/UserGestureIndicator.h:98: // non-suffixed counterparts *must* be called on the main ...
4 years ago (2016-12-12 15:20:47 UTC) #41
kinuko
https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h File third_party/WebKit/Source/platform/UserGestureIndicator.h (right): https://codereview.chromium.org/2555013004/diff/180001/third_party/WebKit/Source/platform/UserGestureIndicator.h#newcode118 third_party/WebKit/Source/platform/UserGestureIndicator.h:118: static bool consumeUserGestureThreadSafe(); On 2016/12/12 15:20:47, Charlie Harrison wrote: ...
4 years ago (2016-12-12 15:37:49 UTC) #42
Charlie Harrison
Thanks! +haraken for web and modules +reillyg for extensions https://codereview.chromium.org/2555013004/diff/200001/third_party/WebKit/Source/core/frame/DOMTimer.cpp File third_party/WebKit/Source/core/frame/DOMTimer.cpp (right): https://codereview.chromium.org/2555013004/diff/200001/third_party/WebKit/Source/core/frame/DOMTimer.cpp#newcode94 third_party/WebKit/Source/core/frame/DOMTimer.cpp:94: ...
4 years ago (2016-12-12 15:44:39 UTC) #46
haraken
LGTM > Calling isMainThread involves doing a thread id syscall which can be quite slow ...
4 years ago (2016-12-12 15:48:30 UTC) #47
Charlie Harrison
On 2016/12/12 15:48:30, haraken wrote: > LGTM > > > Calling isMainThread involves doing a ...
4 years ago (2016-12-12 15:50:51 UTC) #48
haraken
On 2016/12/12 15:50:51, Charlie Harrison wrote: > On 2016/12/12 15:48:30, haraken wrote: > > LGTM ...
4 years ago (2016-12-12 15:57:52 UTC) #49
Reilly Grant (use Gerrit)
lgtm
4 years ago (2016-12-12 21:29:12 UTC) #52
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/2555013004/220001
4 years ago (2016-12-12 21:35:03 UTC) #55
commit-bot: I haz the power
Committed patchset #12 (id:220001)
4 years ago (2016-12-12 22:47:20 UTC) #58
commit-bot: I haz the power
4 years ago (2016-12-12 22:51:19 UTC) #60
Message was sent while issue was closed.
Patchset 12 (id:??) landed as
https://crrev.com/8bcf27f192944e2eea90a846156a770d4ca939fc
Cr-Commit-Position: refs/heads/master@{#437941}

Powered by Google App Engine
This is Rietveld 408576698