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

Issue 189483004: WontFix: Add fast path for id/name/style/class in getAttribute/setAttribute bindings. (Closed)

Created:
6 years, 9 months ago by dshwang
Modified:
6 years, 9 months ago
Reviewers:
pdr., Inactive, eseidel
CC:
blink-reviews, arv+blink, sof, eae+blinkwatch, dglazkov+blink, adamk+blink_chromium.org, watchdog-blink-watchlist_google.com, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

WontFix: Add fast path for id/name/class/style in getAttribute/setAttribute bindings. Cherry-picked the patch by akling@apple.com from <https://webkit.org/b/129851>; Since these attributes are so commonly read and modified via the DOM bindings, add a little fast path to avoid doing AtomicString lookups for those names when they are used in friendly lowercase. fastGetAttribute() in WebKit can handles style attribute, but fastGetAttribute() in Blink does not support that, so there is relevant changes. Test: PerformanceTests/Bindings/get-attribute.html, PerformanceTests/Bindings/get-attribute-rare.html, PerformanceTests/Bindings/set-attribute.html, PerformanceTests/Bindings/set-attribute-rare.html Both were run on my Ivy Bridge laptop. PerformanceTests/Bindings/get-attribute.html -> 11% improvement Before : Avg get-attribute: 329.751776runs/s After : Avg get-attribute: 367.252965runs/s PerformanceTests/Bindings/get-attribute-rare.html -> 51% regression Before : Avg get-attribute-href: 329.339992runs/s After : Avg get-attribute-href: 159.540438runs/s PerformanceTests/Bindings/set-attribute.html -> 19% improvement Before : Avg set-attribute: 809.784217runs/s After : Avg set-attribute: 965.404519runs/s PerformanceTests/Bindings/set-attribute-rare.html -> 45% regression Avg set-attribute-href: 756.714409runs/s Avg set-attribute-href: 415.186785runs/s BUG=350380

Patch Set 1 #

Total comments: 1

Patch Set 2 : Exclude style tag in fast path because blink don't support #

Total comments: 10

Patch Set 3 : deal with svg #

Total comments: 5

Patch Set 4 : Use String for localName, and remove duplicated code #

Total comments: 3

Patch Set 5 : use enum instead of bool #

Patch Set 6 : Add performance tests about rare attribute. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+53 lines, -6 lines) Patch
A + PerformanceTests/Bindings/get-attribute-rare.html View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
A + PerformanceTests/Bindings/set-attribute-rare.html View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M Source/core/dom/Element.h View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M Source/core/dom/Element.cpp View 1 2 3 4 1 chunk +44 lines, -0 lines 0 comments Download
M Source/core/dom/Element.idl View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 30 (0 generated)
dshwang
6 years, 9 months ago (2014-03-07 13:10:08 UTC) #1
Inactive
Would be good to make sure we don't regress other attributes. Is there an noticeable ...
6 years, 9 months ago (2014-03-07 13:23:09 UTC) #2
Inactive
Could you provide the numbers for the following performance test for e.g.? PerformanceTests/Bindings/get-attribute.html
6 years, 9 months ago (2014-03-07 13:30:21 UTC) #3
dshwang
On 2014/03/07 13:30:21, Chris Dumez wrote: > Could you provide the numbers for the following ...
6 years, 9 months ago (2014-03-07 13:42:49 UTC) #4
dshwang
Let me make more readable. PerformanceTests/Bindings/get-attribute.html -> 16% improvement Before : Avg get-attribute: 273.565932runs/s After ...
6 years, 9 months ago (2014-03-07 13:44:41 UTC) #5
Inactive
On 2014/03/07 13:44:41, dshwang wrote: > Let me make more readable. > > PerformanceTests/Bindings/get-attribute.html -> ...
6 years, 9 months ago (2014-03-07 14:02:44 UTC) #6
dshwang
On 2014/03/07 14:02:44, Chris Dumez wrote: > Looks convincing to me. Please update as per ...
6 years, 9 months ago (2014-03-07 14:21:32 UTC) #7
Inactive
On 2014/03/07 14:21:32, dshwang wrote: > On 2014/03/07 14:02:44, Chris Dumez wrote: > > Looks ...
6 years, 9 months ago (2014-03-07 15:24:38 UTC) #8
dshwang
On 2014/03/07 15:24:38, Chris Dumez wrote: > Could you check the failures on the try ...
6 years, 9 months ago (2014-03-07 17:29:15 UTC) #9
dshwang
I fix the layout test failure. https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode2970 Source/core/dom/Element.cpp:2970: return false; Blink ...
6 years, 9 months ago (2014-03-10 18:43:20 UTC) #10
Inactive
https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode936 Source/core/dom/Element.cpp:936: void Element::bindingsSetAttribute(const String& localName, const String& newValue, ExceptionState& exceptionState) ...
6 years, 9 months ago (2014-03-10 18:46:44 UTC) #11
dshwang
On 2014/03/10 18:46:44, Chris Dumez wrote: > https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp > File Source/core/dom/Element.cpp (right): > > https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode936 ...
6 years, 9 months ago (2014-03-10 18:50:32 UTC) #12
Inactive
https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode923 Source/core/dom/Element.cpp:923: return HTMLNames::classAttr; Technically, I believe we cannot do a ...
6 years, 9 months ago (2014-03-10 18:58:26 UTC) #13
dshwang
https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode2973 Source/core/dom/Element.cpp:2973: return !toSVGElement(this)->isAnimatableAttribute(name); Thanks Chris. here is svg consideration. How ...
6 years, 9 months ago (2014-03-10 19:48:59 UTC) #14
Inactive
See one proposal below. Feel free to propose something better. https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode911 ...
6 years, 9 months ago (2014-03-10 19:56:23 UTC) #15
Inactive
https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode936 Source/core/dom/Element.cpp:936: void Element::bindingsSetAttribute(const String& localName, const String& newValue, ExceptionState& exceptionState) ...
6 years, 9 months ago (2014-03-10 20:04:14 UTC) #16
Inactive
On 2014/03/10 20:04:14, Chris Dumez wrote: > https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp > File Source/core/dom/Element.cpp (right): > > https://codereview.chromium.org/189483004/diff/20001/Source/core/dom/Element.cpp#newcode936 ...
6 years, 9 months ago (2014-03-10 20:10:01 UTC) #17
dshwang
On 2014/03/10 20:10:01, Chris Dumez wrote: > On 2014/03/10 20:04:14, Chris Dumez wrote: > > ...
6 years, 9 months ago (2014-03-10 20:27:09 UTC) #18
dshwang
I update this CL as Chris's suggestion. setAttribute accelerates id/name/class/style attributes getAttribute accelerates id/name/class attributes. ...
6 years, 9 months ago (2014-03-11 07:49:09 UTC) #19
dshwang
I measure performance test between using String and using AtomicString. The results for both are ...
6 years, 9 months ago (2014-03-11 07:50:20 UTC) #20
Inactive
https://codereview.chromium.org/189483004/diff/40001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/40001/Source/core/dom/Element.cpp#newcode918 Source/core/dom/Element.cpp:918: if (length == 2 && name[0] == 'i' && ...
6 years, 9 months ago (2014-03-11 13:48:32 UTC) #21
dshwang
On 2014/03/11 13:48:32, Chris Dumez wrote: Thank you for great review. > https://codereview.chromium.org/189483004/diff/40001/Source/core/dom/Element.cpp > File ...
6 years, 9 months ago (2014-03-11 14:46:40 UTC) #22
Inactive
Much better but I still have a couple of comments. https://codereview.chromium.org/189483004/diff/60001/Source/core/dom/Element.cpp File Source/core/dom/Element.cpp (right): https://codereview.chromium.org/189483004/diff/60001/Source/core/dom/Element.cpp#newcode911 ...
6 years, 9 months ago (2014-03-11 15:43:30 UTC) #23
Inactive
@dshwang, can you please make sure the results in your CL description are up-to-date? Results ...
6 years, 9 months ago (2014-03-11 15:46:27 UTC) #24
dshwang
On 2014/03/11 15:46:27, Chris Dumez wrote: > @dshwang, can you please make sure the results ...
6 years, 9 months ago (2014-03-11 16:48:55 UTC) #25
Inactive
There is a typo in the description: "WebKie" -> "WebKit". The patch looks good now. ...
6 years, 9 months ago (2014-03-11 17:19:04 UTC) #26
dshwang
On 2014/03/11 17:19:04, Chris Dumez wrote: > There is a typo in the description: "WebKie" ...
6 years, 9 months ago (2014-03-11 18:16:55 UTC) #27
Inactive
On 2014/03/11 18:16:55, dshwang wrote: > On 2014/03/11 17:19:04, Chris Dumez wrote: > > There ...
6 years, 9 months ago (2014-03-11 18:23:50 UTC) #28
dshwang
On 2014/03/11 18:23:50, Chris Dumez wrote: > Ouch... 45-50% regression on slow-path attributes is bad ...
6 years, 9 months ago (2014-03-11 18:34:22 UTC) #29
Inactive
6 years, 9 months ago (2014-03-11 18:40:41 UTC) #30
Message was sent while issue was closed.
On 2014/03/11 18:34:22, dshwang wrote:
> On 2014/03/11 18:23:50, Chris Dumez wrote:
> > Ouch... 45-50% regression on slow-path attributes is bad indeed (much bigger
> > than the improvement on the fast path). It is a good thing you checked,
thanks
> > for taking the time to verify! It is unfortunate since you spent time on
this
> > but I also agree that this optimization does not seem to be worth it.
> 
> Yes, sorry for taking your amount of time for invalid optimization. I need to
> notify WebKit dev also.

I'm always happy to discuss dom optimizations.
You can try your new perf tests on WebKit side, it may yield different results
there.
The code bases and also the patches are slightly different.

Powered by Google App Engine
This is Rietveld 408576698