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

Issue 1176303008: Avoid argument copying in WTF hash-based containers (Closed)

Created:
5 years, 6 months ago by Mikhail
Modified:
5 years, 4 months ago
Reviewers:
tkent, Erik Corry, Nico
CC:
blink-reviews, blink-reviews-wtf_chromium.org, Mike West, rune, Timothy Loh
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Avoid argument copying in WTF hash-based containers The 'KeyPeekInType' used by WTF hash-based containers is declared as 'const T&' for most of the classes, the const reference however was lost in the previous implemntation of HashTable 'contains(KeyPeekInType)' and 'find(KeyPeekInType)' methods as it was deduced to 'T' in the further sub-calls (i.e. template<typename HashTranslator, typename T> ValueType* lookup(T)). This led to unneeded argument copying (2 times per each contains/find call!) and it significantly affected the performance for containers having String or AtomicString key types, such containers are widely used for example in Blink core/css code. Below is the improvement of some randomly taken CSS performance tests results after the patch is applied (Linux desktop x64): StyleSheetInsert.html - 3.4% before: avg 45.81039999999348 ms median 45.569000000000415 ms stdev 1.1590581657568524 ms min 44.60299999993822 ms max 48.70600000003833 ms after: avg 44.08615000000964 ms median 44.036000000005515 ms stdev 0.5594090185250097 ms min 43.43600000004244 ms max 45.64000000004853 ms AttributeDescendantSelector.html - 7% before: avg 630.7230679370987 runs/s median 631.5237186271941 runs/s stdev 1.8378708385437512 runs/s min 627.7266878002865 runs/s max 632.970649942742 runs/s after: avg 676.0284840644981 runs/s median 675.6238838914546 runs/s stdev 2.1139085234317543 runs/s min 673.3117355645138 runs/s max 678.8715588063761 runs/s CSSPropertyUpdateValue.html - 1.7% before: avg 16820.037469368264 runs/s median 16812.805624173976 runs/s stdev 70.629520115344 runs/s min 16647.24488097132 runs/s max 16989.1959332111 runs/s after: avg 17089.45990524665 runs/s median 17093.550656512787 runs/s stdev 54.79615592821426 runs/s min 16962.157162336156 runs/s max 17179.8873301988 runs/s This patch also reduces content_shell binary size by 52KB. Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=199826

Patch Set 1 #

Total comments: 2

Patch Set 2 : counter -> s_counter #

Patch Set 3 : Fix unit test on Win #

Patch Set 4 : Disabled test for Debug config. on Win. #

Patch Set 5 : Disabled test on Win if assertions enabled #

Patch Set 6 : Fix NRVO in test key traits on Win #

Total comments: 1

Patch Set 7 : Added explanation comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+75 lines, -11 lines) Patch
M Source/wtf/HashMapTest.cpp View 1 2 3 4 5 6 1 chunk +56 lines, -0 lines 0 comments Download
M Source/wtf/HashTable.h View 1 2 3 4 chunks +19 lines, -11 lines 0 comments Download

Messages

Total messages: 25 (5 generated)
Mikhail
PTAL
5 years, 6 months ago (2015-06-18 15:04:44 UTC) #2
tkent
https://codereview.chromium.org/1176303008/diff/1/Source/wtf/HashMapTest.cpp File Source/wtf/HashMapTest.cpp (right): https://codereview.chromium.org/1176303008/diff/1/Source/wtf/HashMapTest.cpp#newcode317 Source/wtf/HashMapTest.cpp:317: static int counter; counter -> s_counter https://codereview.chromium.org/1176303008/diff/1/Source/wtf/HashTable.h File Source/wtf/HashTable.h ...
5 years, 6 months ago (2015-06-18 23:41:50 UTC) #3
Mikhail
On 2015/06/18 23:41:50, unavailable_until_Jul3 wrote: > https://codereview.chromium.org/1176303008/diff/1/Source/wtf/HashMapTest.cpp > File Source/wtf/HashMapTest.cpp (right): > > https://codereview.chromium.org/1176303008/diff/1/Source/wtf/HashMapTest.cpp#newcode317 > ...
5 years, 5 months ago (2015-06-29 11:05:24 UTC) #5
Nico
On Mon, Jun 29, 2015 at 4:05 AM, <mikhail.pozdnyakov@intel.com> wrote: > On 2015/06/18 23:41:50, unavailable_until_Jul3 ...
5 years, 5 months ago (2015-06-29 16:12:44 UTC) #6
Mikhail
On 2015/06/29 16:12:44, Nico wrote: > On Mon, Jun 29, 2015 at 4:05 AM, <mailto:mikhail.pozdnyakov@intel.com> ...
5 years, 5 months ago (2015-06-30 10:17:36 UTC) #7
Nico
On 2015/06/30 10:17:36, Mikhail wrote: > On 2015/06/29 16:12:44, Nico wrote: > > On Mon, ...
5 years, 5 months ago (2015-06-30 18:31:32 UTC) #8
tkent
lgtm
5 years, 5 months ago (2015-07-03 00:10:53 UTC) #9
Mikhail
Win bot fails: the newly added test cannot pass on Windows: hashmaptest.cpp(353): error: Value of: ...
5 years, 5 months ago (2015-07-03 12:23:31 UTC) #10
tkent
On 2015/07/03 12:23:31, Mikhail (OOO until Jul 13) wrote: > Right now I do not ...
5 years, 5 months ago (2015-07-06 00:34:28 UTC) #11
Mikhail
On 2015/07/06 00:34:28, tkent wrote: > On 2015/07/03 12:23:31, Mikhail (OOO until Jul 13) wrote: ...
5 years, 5 months ago (2015-07-22 10:11:18 UTC) #12
tkent
On 2015/07/22 10:11:18, Mikhail wrote: > On 2015/07/06 00:34:28, tkent wrote: > > On 2015/07/03 ...
5 years, 5 months ago (2015-07-24 02:19:24 UTC) #13
Mikhail
On 2015/07/24 02:19:24, tkent wrote: > On 2015/07/22 10:11:18, Mikhail wrote: > > On 2015/07/06 ...
5 years, 4 months ago (2015-07-27 14:49:36 UTC) #14
tkent
On 2015/07/27 14:49:36, Mikhail wrote: > > I think the bots use VS2013. > > ...
5 years, 4 months ago (2015-07-27 23:11:47 UTC) #15
Mikhail
On 2015/07/27 23:11:47, tkent wrote: > On 2015/07/27 14:49:36, Mikhail wrote: > > > I ...
5 years, 4 months ago (2015-07-28 14:40:19 UTC) #16
tkent
On 2015/07/28 14:40:19, Mikhail wrote: > Right, when the assertions are enabled (even on release ...
5 years, 4 months ago (2015-07-28 22:26:44 UTC) #17
Mikhail
On 2015/07/28 22:26:44, tkent wrote: > On 2015/07/28 14:40:19, Mikhail wrote: > > Right, when ...
5 years, 4 months ago (2015-07-30 09:18:57 UTC) #18
tkent
lgtm. Thank you for the analysis! https://codereview.chromium.org/1176303008/diff/100001/Source/wtf/HashMapTest.cpp File Source/wtf/HashMapTest.cpp (right): https://codereview.chromium.org/1176303008/diff/100001/Source/wtf/HashMapTest.cpp#newcode340 Source/wtf/HashMapTest.cpp:340: static CopyCounter emptyValue() ...
5 years, 4 months ago (2015-07-30 23:55:54 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1176303008/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1176303008/120001
5 years, 4 months ago (2015-07-31 09:49:16 UTC) #22
commit-bot: I haz the power
Committed patchset #7 (id:120001) as https://src.chromium.org/viewvc/blink?view=rev&revision=199826
5 years, 4 months ago (2015-07-31 12:45:43 UTC) #23
johnme
5 years, 4 months ago (2015-07-31 15:21:05 UTC) #24
Message was sent while issue was closed.
A revert of this CL (patchset #7 id:120001) has been created in
https://codereview.chromium.org/1261953005/ by johnme@chromium.org.

The reason for reverting is: This broke HashMapTest.LookupNoKeyCopies on WebKit
Win7 (dbg) and WebKit Win Oilpan (dbg):

http://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=Has....

Powered by Google App Engine
This is Rietveld 408576698