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

Issue 611953003: Canvas2D Performance: fix the bottleneck of hasInstance during JS binding -- overloading (Closed)

Created:
6 years, 2 months ago by yunchao
Modified:
5 years, 11 months ago
CC:
blink-reviews, blink-reviews-bindings_chromium.org, arv+blink
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Canvas2D Performance: fix the bottleneck of hasInstance during JS binding -- overloading If web app invokes hundreds of drawImage per frame, hasInstance(called by drawImageMethod) will become a bottleneck. Here is test data from content shell on Nexus7 by Linux perf tool: benchmark ratio that hasInstance costs in the whole renderer my local benchmark(draw 1000 sprites) 6.9% speedReading 4.4% FishIETank(1000 fishes) 2.6% GUIMark3 Bitmap 4.0% drawImageMethod is in out/Release/gen/blink/bindings/core/v8/V8CanvasRenderingContext2D.cpp, which is an auto-generated file. It will call hasInstance(eg V8HTMLImageElement::hasInstance) 3 times for every call to drawImage. One is in drawImageMethod directly, the other two are in drawImage*Method, say drawImage1Method. The 2nd call site is redundant if type check has been done by overloading during JS binding. This change removes the 2nd call of hasInstance in drawImageMethod to fix the performance bottleneck. It also benefits similar cases during JS binding. This change improves performance and/or saves power. BUG=416393

Patch Set 1 #

Total comments: 3

Patch Set 2 : add code change in Source/bindings/tests/results/ #

Total comments: 2

Patch Set 3 : remove typecheck for overloads if no optional argument + change toImplWithTypeCheck -> toImpl if th… #

Total comments: 1

Patch Set 4 : remove redundant call to hasInstance if the argument has been type checked by overloading #

Patch Set 5 : add test cases of TypeChecking interface for overloading #

Patch Set 6 : update auto-generated code for test cases I added, the change in JS binding is applied #

Total comments: 8

Patch Set 7 : comments + coding style" #

Total comments: 10

Patch Set 8 : update code accordingly (w/ redundant type check for overload resolution) #

Patch Set 9 : update code accordingly (w/o redundant type check for overload resolution) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+444 lines, -1 line) Patch
M Source/bindings/scripts/v8_interface.py View 1 2 3 4 5 6 7 8 2 chunks +13 lines, -0 lines 0 comments Download
M Source/bindings/scripts/v8_methods.py View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/templates/methods.cpp View 1 2 3 4 5 6 7 1 chunk +2 lines, -1 line 0 comments Download
M Source/bindings/tests/idls/core/TestObject.idl View 1 2 3 4 5 6 7 1 chunk +14 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/core/V8TestObject.cpp View 1 2 3 4 5 6 7 8 2 chunks +414 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (2 generated)
yunchao
PTAL. Thanks a lot!
6 years, 2 months ago (2014-09-29 09:43:49 UTC) #2
Jens Widell
Quick comment: Please run $ Tools/Scripts/run-bindings-tests --reset-results and add the modifications it does to the ...
6 years, 2 months ago (2014-09-29 09:50:58 UTC) #3
yunchao
On 2014/09/29 09:50:58, Jens Widell wrote: > Quick comment: Please run > > $ Tools/Scripts/run-bindings-tests ...
6 years, 2 months ago (2014-09-29 09:58:05 UTC) #4
Jens Widell
If I may make a suggestion: Split this CL into two; one which addresses the ...
6 years, 2 months ago (2014-09-29 10:04:46 UTC) #5
Jens Widell
On 2014/09/29 10:04:46, Jens Widell wrote: > The latter is quite a bit more complicated, ...
6 years, 2 months ago (2014-09-29 10:24:22 UTC) #6
yunchao
Quick comment: Thanks for your review, Jens. I will submit a new patch set tomorrow. ...
6 years, 2 months ago (2014-09-30 09:17:29 UTC) #7
Jens Widell
https://codereview.chromium.org/611953003/diff/20001/Source/bindings/scripts/v8_interface.py File Source/bindings/scripts/v8_interface.py (right): https://codereview.chromium.org/611953003/diff/20001/Source/bindings/scripts/v8_interface.py#newcode777 Source/bindings/scripts/v8_interface.py:777: for argument in arguments: On 2014/09/30 09:17:29, yunchao wrote: ...
6 years, 2 months ago (2014-09-30 09:38:22 UTC) #8
yunchao
On 2014/09/30 09:38:22, Jens Widell wrote: > https://codereview.chromium.org/611953003/diff/20001/Source/bindings/scripts/v8_interface.py > File Source/bindings/scripts/v8_interface.py (right): > > https://codereview.chromium.org/611953003/diff/20001/Source/bindings/scripts/v8_interface.py#newcode777 ...
6 years, 2 months ago (2014-10-02 10:46:19 UTC) #9
Jens Widell
On 2014/10/02 10:46:19, yunchao wrote: > On 2014/09/30 09:38:22, Jens Widell wrote: > > > ...
6 years, 2 months ago (2014-10-02 10:51:41 UTC) #10
yunchao
https://codereview.chromium.org/611953003/diff/40001/Source/bindings/scripts/v8_interface.py File Source/bindings/scripts/v8_interface.py (right): https://codereview.chromium.org/611953003/diff/40001/Source/bindings/scripts/v8_interface.py#newcode757 Source/bindings/scripts/v8_interface.py:757: if argument['idl_type_object'].is_wrapper_type and method['number_of_required_arguments'] == method['number_of_arguments']: both number_of_required_arguments and ...
6 years, 2 months ago (2014-10-02 10:51:56 UTC) #11
yunchao
On 2014/10/02 10:51:41, Jens Widell wrote: > On 2014/10/02 10:46:19, yunchao wrote: > > On ...
6 years, 2 months ago (2014-10-02 11:14:48 UTC) #12
yunchao
On 2014/10/02 11:14:48, yunchao wrote: > On 2014/10/02 10:51:41, Jens Widell wrote: > > On ...
6 years, 2 months ago (2014-10-10 03:03:00 UTC) #13
Jens Widell
https://codereview.chromium.org/611953003/diff/120001/Source/bindings/scripts/v8_interface.py File Source/bindings/scripts/v8_interface.py (right): https://codereview.chromium.org/611953003/diff/120001/Source/bindings/scripts/v8_interface.py#newcode756 Source/bindings/scripts/v8_interface.py:756: for argument, method in arguments_methods: Could you add a ...
6 years, 2 months ago (2014-10-10 10:14:53 UTC) #14
yunchao
Thanks for your review, Jens. I have updated the code accordingly. Please take a look ...
6 years, 2 months ago (2014-10-10 11:40:49 UTC) #15
Nils Barth (inactive)
+bashi, who's working on union type support. Thanks for submitting this Yunchao! Could you give ...
6 years, 2 months ago (2014-10-13 14:36:57 UTC) #17
yunchao
Thanks for you review, nbarth@. I have updated the code accordingly. This change and another ...
6 years, 2 months ago (2014-10-14 06:58:49 UTC) #18
Nils Barth (inactive)
Thanks for explaining Yunchao! Question: * I don't see the *bottom line* impact: what is ...
6 years, 2 months ago (2014-10-14 23:00:08 UTC) #19
yunchao
On 2014/10/14 23:00:08, Nils Barth (inactive) wrote: > Thanks for explaining Yunchao! > Question: > ...
6 years, 2 months ago (2014-10-15 08:17:05 UTC) #20
yunchao
On 2014/10/14 23:00:08, Nils Barth (inactive) wrote: > Thanks for explaining Yunchao! > Question: > ...
6 years, 2 months ago (2014-10-20 07:25:25 UTC) #21
Jens Widell
yunchao@: with https://codereview.chromium.org/703783004/, drawImage() uses a union type for the first argument, so is only ...
6 years, 1 month ago (2014-11-14 12:12:26 UTC) #22
yunchao
6 years, 1 month ago (2014-11-17 06:20:56 UTC) #23
On 2014/11/14 12:12:26, Jens Widell wrote:
> yunchao@: with https://codereview.chromium.org/703783004/, drawImage() uses a
> union type for the first argument, so is only overloaded for different number
of
> arguments. This patch thus no longer affects drawImage() at all, and the
number
> of hasInstance() checks should now be optimized to one.
> 
> You may want to rerun your benchmarks (with no patches applied), and close
this
> CL.

Thanks for your patch, Jens. I will double check the number of call sites to
hasInstance several days later when I have time.

Powered by Google App Engine
This is Rietveld 408576698