New issue
Advanced search Search tips

Issue 624220 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 620142
issue 577989



Sign in to add a comment

Improve performance of HTMLSelectElement by small hacks

Project Member Reported by tkent@chromium.org, Jun 29 2016

Issue description

Sub-task of  Issue 577989 
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jun 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6aa050448c3f5a8e6749e059ec9ec62adb685a70

commit 6aa050448c3f5a8e6749e059ec9ec62adb685a70
Author: tkent <tkent@chromium.org>
Date: Wed Jun 29 04:10:28 2016

Improve performance to remove an OPTION from a SELECT element.

This CL optimize HTMLSelectElement::resetToDefaultSelection(). We can quit the
loop if a selected OPTION was removed.

Removing 20,000 OPTIONs: 7,595ms -> 6,358ms

BUG= 620142 ,  624220 

Review-Url: https://codereview.chromium.org/2108883003
Cr-Commit-Position: refs/heads/master@{#402709}

[modify] https://crrev.com/6aa050448c3f5a8e6749e059ec9ec62adb685a70/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/6aa050448c3f5a8e6749e059ec9ec62adb685a70/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Project Member

Comment 2 by bugdroid1@chromium.org, Jun 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8881397e890dd70a187a957ae6910f141d378eb5

commit 8881397e890dd70a187a957ae6910f141d378eb5
Author: tkent <tkent@chromium.org>
Date: Wed Jun 29 04:41:22 2016

Improve performance of SELECT element by optimizing Vector.

Replace Vector::clear() with Vector::resize(0) to avoid to deallocate Vector
buffers.

Removing 20,000 OPTIONs: 7,595ms -> 5,779ms

BUG= 620142 ,  624220 

Review-Url: https://codereview.chromium.org/2105863003
Cr-Commit-Position: refs/heads/master@{#402720}

[modify] https://crrev.com/8881397e890dd70a187a957ae6910f141d378eb5/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Project Member

Comment 3 by bugdroid1@chromium.org, Jun 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8c8740e3119f92898875bbf06cb46537ac832533

commit 8c8740e3119f92898875bbf06cb46537ac832533
Author: tkent <tkent@chromium.org>
Date: Wed Jun 29 04:53:20 2016

Remove unnecessary code from HTMLOptGroupElement.

* We don't need to call setRecalcListItems() in childrenChanged() because
  HTMLOptionElement::insertedInto() and removedFrom() do it.

* We don't need to call setRecalcListItems() in parseAttribute(). OPTGROUP
  attributes don't affect HTMLSelectElement::m_listItems.
  The code exists since http://trac.webkit.org/changeset/4 .

BUG= 624220 

Review-Url: https://codereview.chromium.org/2105243002
Cr-Commit-Position: refs/heads/master@{#402722}

[modify] https://crrev.com/8c8740e3119f92898875bbf06cb46537ac832533/third_party/WebKit/Source/core/html/HTMLOptGroupElement.cpp
[modify] https://crrev.com/8c8740e3119f92898875bbf06cb46537ac832533/third_party/WebKit/Source/core/html/HTMLOptGroupElement.h

Project Member

Comment 4 by bugdroid1@chromium.org, Jun 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/25445ac85b61754a12be2ccc65ddb1ef5aa96635

commit 25445ac85b61754a12be2ccc65ddb1ef5aa96635
Author: tkent <tkent@chromium.org>
Date: Wed Jun 29 10:03:22 2016

Improve performance of HTMLSelectElement::setActiveSelectionAnchor().

Do not update m_cachedStateForActiveSelection if it's a
menulist. m_cachedStateForActiveSelection is used only in listboxes.

Removing 20,000 OPTIONs: 4,787ms -> 3,772ms

BUG= 620142 ,  624220 

Review-Url: https://codereview.chromium.org/2104883004
Cr-Commit-Position: refs/heads/master@{#402765}

[modify] https://crrev.com/25445ac85b61754a12be2ccc65ddb1ef5aa96635/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/25445ac85b61754a12be2ccc65ddb1ef5aa96635/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Project Member

Comment 5 by bugdroid1@chromium.org, Jun 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/454e5952a2623d05d272939c01b4b09535be40a3

commit 454e5952a2623d05d272939c01b4b09535be40a3
Author: tkent <tkent@chromium.org>
Date: Wed Jun 29 10:12:19 2016

Improve performance of HTMLSelectElement::resetToDefaultSelection().

If we remove a selected OPTION from a SELECT element, selectOption() called from
resetToDefaultSelection() doesn't need to call deselectItemsWithoutValidation()
because there are no other selected OPTIONs.

- !multiple() doesn't imply DeselectOtherOptions.  Updates existing callsites of
  selectOption().
- Make SelectOptionFlags mandatory.

Removing 20,000 OPTIONs: 6,348ms -> 5,324ms

BUG= 620142 ,  624220 

Review-Url: https://codereview.chromium.org/2110003002
Cr-Commit-Position: refs/heads/master@{#402767}

[modify] https://crrev.com/454e5952a2623d05d272939c01b4b09535be40a3/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/454e5952a2623d05d272939c01b4b09535be40a3/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Project Member

Comment 6 by bugdroid1@chromium.org, Jun 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5850ba2952d13224b95b9cd78248d4216eb76d96

commit 5850ba2952d13224b95b9cd78248d4216eb76d96
Author: tkent <tkent@chromium.org>
Date: Wed Jun 29 11:46:42 2016

Remove redundant calls to HTMLSelectElement::setRecalcListItems().

When we remove or insert an OPTION from/to a SELECT element,
setRecalcListItems() was called twice.
 - HTMLSelectElement::childrenChanged()
 - HTMLSelectElement::optionInserted() or optionRemoved().

Also, it was called even when a text node is added to a SELECT element. This CL
fixes them.

We stops to override childrenChange(). HTMLOptGroupElement and HTMLHRElement
override insertedInto() and removedFrom(), and they notify these events to the
owner SELECT element like HTMLOptionElement does.

This is a preparation to optimize setRecalcListItems().

BUG= 624220 

Review-Url: https://codereview.chromium.org/2109993003
Cr-Commit-Position: refs/heads/master@{#402781}

[modify] https://crrev.com/5850ba2952d13224b95b9cd78248d4216eb76d96/third_party/WebKit/Source/core/html/HTMLHRElement.cpp
[modify] https://crrev.com/5850ba2952d13224b95b9cd78248d4216eb76d96/third_party/WebKit/Source/core/html/HTMLHRElement.h
[modify] https://crrev.com/5850ba2952d13224b95b9cd78248d4216eb76d96/third_party/WebKit/Source/core/html/HTMLOptGroupElement.cpp
[modify] https://crrev.com/5850ba2952d13224b95b9cd78248d4216eb76d96/third_party/WebKit/Source/core/html/HTMLOptGroupElement.h
[modify] https://crrev.com/5850ba2952d13224b95b9cd78248d4216eb76d96/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/5850ba2952d13224b95b9cd78248d4216eb76d96/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Project Member

Comment 7 by bugdroid1@chromium.org, Jun 30 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ef9c38f033c0f5b11defe2210d2d00737c41b76e

commit ef9c38f033c0f5b11defe2210d2d00737c41b76e
Author: tkent <tkent@chromium.org>
Date: Thu Jun 30 05:26:52 2016

Improve performance of HTMLSelectElement::m_listItems update.

This CL introduces a fast path to update m_listItems directly instead of throwing
it away and reconstructing it. The fast path supports:
 - Prepend an OPTION to a SELECT element
 - Append an OPTION to a SELECT element
 - Remove an OPTION child from a SELECT element or an OPTGROUP element.

Removing 20,000 OPTIONs: 2,813ms -> 200ms

BUG= 620142 ,  624220 

Review-Url: https://codereview.chromium.org/2110303002
Cr-Commit-Position: refs/heads/master@{#403093}

[modify] https://crrev.com/ef9c38f033c0f5b11defe2210d2d00737c41b76e/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/ef9c38f033c0f5b11defe2210d2d00737c41b76e/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Comment 8 by tkent@chromium.org, Jun 30 2016

Labels: Merge-Request-52 M-52
Status: Fixed (was: Started)
I'd like to merge #1, #2, #4, and #5.

Comment 9 by dimu@google.com, Jul 1 2016

Labels: -Merge-Request-52 Merge-Approved-52 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M52 (branch: 2743)
Project Member

Comment 10 by bugdroid1@chromium.org, Jul 1 2016

Labels: -merge-approved-52 merge-merged-2743
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ee4ea0dc58d29004697c7357dc7aadca01f74c03

commit ee4ea0dc58d29004697c7357dc7aadca01f74c03
Author: Kent Tamura <tkent@chromium.org>
Date: Fri Jul 01 05:34:56 2016

Merge "Improve performance to remove an OPTION from a SELECT element." to M52

This CL optimize HTMLSelectElement::resetToDefaultSelection(). We can quit the
loop if a selected OPTION was removed.

Removing 20,000 OPTIONs: 7,595ms -> 6,358ms

BUG= 620142 ,  624220 

Review-Url: https://codereview.chromium.org/2108883003
Cr-Commit-Position: refs/heads/master@{#402709}
(cherry picked from commit 6aa050448c3f5a8e6749e059ec9ec62adb685a70)

Review URL: https://codereview.chromium.org/2113953002 .

Cr-Commit-Position: refs/branch-heads/2743@{#560}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/ee4ea0dc58d29004697c7357dc7aadca01f74c03/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/ee4ea0dc58d29004697c7357dc7aadca01f74c03/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Project Member

Comment 11 by bugdroid1@chromium.org, Jul 1 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4477cc6040e3ebc7300c372a8d58fab20c96eb59

commit 4477cc6040e3ebc7300c372a8d58fab20c96eb59
Author: Kent Tamura <tkent@chromium.org>
Date: Fri Jul 01 05:42:35 2016

Merge "Improve performance of SELECT element by optimizing Vector." to M52

Replace Vector::clear() with Vector::resize(0) to avoid to deallocate Vector
buffers.

Removing 20,000 OPTIONs: 7,595ms -> 5,779ms

BUG= 624220 

Review-Url: https://codereview.chromium.org/2105863003
Cr-Commit-Position: refs/heads/master@{#402720}
(cherry picked from commit 8881397e890dd70a187a957ae6910f141d378eb5)

Review URL: https://codereview.chromium.org/2118743002 .

Cr-Commit-Position: refs/branch-heads/2743@{#561}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/4477cc6040e3ebc7300c372a8d58fab20c96eb59/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Project Member

Comment 12 by bugdroid1@chromium.org, Jul 1 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/195e6941595c73f8fbcf09d1eb4773e82dd409d8

commit 195e6941595c73f8fbcf09d1eb4773e82dd409d8
Author: Kent Tamura <tkent@chromium.org>
Date: Fri Jul 01 05:48:28 2016

Merge "Improve performance of HTMLSelectElement::setActiveSelectionAnchor()." to M52.

Do not update m_cachedStateForActiveSelection if it's a
menulist. m_cachedStateForActiveSelection is used only in listboxes.

Removing 20,000 OPTIONs: 4,787ms -> 3,772ms

BUG= 624220 

Review-Url: https://codereview.chromium.org/2104883004
Cr-Commit-Position: refs/heads/master@{#402765}
(cherry picked from commit 25445ac85b61754a12be2ccc65ddb1ef5aa96635)

Review URL: https://codereview.chromium.org/2115783002 .

Cr-Commit-Position: refs/branch-heads/2743@{#562}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/195e6941595c73f8fbcf09d1eb4773e82dd409d8/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/195e6941595c73f8fbcf09d1eb4773e82dd409d8/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Project Member

Comment 13 by bugdroid1@chromium.org, Jul 1 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6fa87e050f4dcf0b0c54704b6916a0568d496c71

commit 6fa87e050f4dcf0b0c54704b6916a0568d496c71
Author: Kent Tamura <tkent@chromium.org>
Date: Fri Jul 01 05:53:53 2016

Merge "Improve performance of HTMLSelectElement::resetToDefaultSelection()." to M52.

If we remove a selected OPTION from a SELECT element, selectOption() called from
resetToDefaultSelection() doesn't need to call deselectItemsWithoutValidation()
because there are no other selected OPTIONs.

- !multiple() doesn't imply DeselectOtherOptions.  Updates existing callsites of
  selectOption().
- Make SelectOptionFlags mandatory.

Removing 20,000 OPTIONs: 6,348ms -> 5,324ms

BUG= 624220 

Review-Url: https://codereview.chromium.org/2110003002
Cr-Commit-Position: refs/heads/master@{#402767}
(cherry picked from commit 454e5952a2623d05d272939c01b4b09535be40a3)

Review URL: https://codereview.chromium.org/2108503008 .

Cr-Commit-Position: refs/branch-heads/2743@{#563}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/6fa87e050f4dcf0b0c54704b6916a0568d496c71/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
[modify] https://crrev.com/6fa87e050f4dcf0b0c54704b6916a0568d496c71/third_party/WebKit/Source/core/html/HTMLSelectElement.h

Labels: TE-Verfied-M52 TE-Verified-52.0.2743.75
Tested the issue on windows 8.1, Linux Ubuntu 14.04 and Mac 10.11.5 using chrome version 52.0.2743.75 as per the fiddle https://jsfiddle.net/qLt94cvc/ given in  Issue 620142  - approx 1.6 sec taken after clicking ok on adding! popup

Please find the screencast

Adding TE-Verified labels
624220.mov
5.9 MB Download

Sign in to add a comment