New issue
Advanced search Search tips

Issue 700452 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug



Sign in to add a comment

Reduce the number of ObjectPaintProperties

Project Member Reported by pdr@chromium.org, Mar 10 2017

Issue description

When preparing a presentation about paint properties I noticed we are creating unnecessary numbers of ObjectPaintProperty objects.

stats on google.com search for dogs
stats.frames: 1
stats.layoutObjects: 1025
stats.objectPaintProps: 641
  paintOffsetTranslation: 2
  transform: 3
  effect: 0
  filter: 0
  mask: 0
  maskClip: 0
  cssClip: 0
  cssClipFixedPosition: 0
  innerBorderRadiusClip: 5
  overflowClip: 86
  perspective: 0
  svgLocalToBorderBoxTransform: 6
  scrollTranslation: 0
  scrollbarPaintOffset: 0
  localBorderBoxProperties: 641
  contentsProperties: 2

stats on new york times:
stats.frames: 11
stats.layoutObjects: 5525
stats.objectPaintProps: 3726
  paintOffsetTranslation: 4
  transform: 7
  effect: 0
  filter: 0
  mask: 0
  maskClip: 0
  cssClip: 16
  cssClipFixedPosition: 0
  innerBorderRadiusClip: 4
  overflowClip: 132
  perspective: 0
  svgLocalToBorderBoxTransform: 2
  scrollTranslation: 0
  scrollbarPaintOffset: 0
  localBorderBoxProperties: 3725
  contentsProperties: 5

https://codereview.chromium.org/2748443002

Two optimization ideas:
1) Do not create so many ObjectPaintProperties. Because paint offset is no longer tracked in the property tree walk, I don't think we need a many.
2) Move localBorderBox properties off ObjectPaintProperties.

I won't have time to tackle this before the presentation Wednesday so leaving as available for now.
 
Labels: PaintTeamTriaged-20170310 BugSource-Team
Owner: wangxianzhu@chromium.org
Status: Assigned (was: Available)
https://codereview.chromium.org/2750463003 (based on pdr@'s first optimization) shows improved stats:

stats on google.com search for dogs
stats.frames: 1
stats.layoutObjects: 1015
stats.objectPaintProps: 220
  nonLayers: 7
  paintOffsetTranslation: 2
  transform: 3
  effect: 0
  filter: 0
  mask: 0
  maskClip: 0
  cssClip: 0
  cssClipFixedPosition: 0
  innerBorderRadiusClip: 6
  overflowClip: 86
  perspective: 0
  svgLocalToBorderBoxTransform: 6
  scrollTranslation: 0
  scrollbarPaintOffset: 0
  localBorderBoxProperties: 172
  localBorderBoxProperties only: 133
  contentsProperties: 2

stats on new york times:
stats.frames: 11
stats.layoutObjects: 5560
stats.objectPaintProps: 456
  nonLayers: 39
  paintOffsetTranslation: 1
  transform: 31
  effect: 0
  filter: 0
  mask: 0
  maskClip: 0
  cssClip: 16
  cssClipFixedPosition: 0
  innerBorderRadiusClip: 3
  overflowClip: 128
  perspective: 0
  svgLocalToBorderBoxTransform: 5
  scrollTranslation: 0
  scrollbarPaintOffset: 0
  localBorderBoxProperties: 382
  localBorderBoxProperties only: 291
  contentsProperties: 2

The numbers of localBorderBoxProperties dropped a lot, but there are still many ObjectPaintProperties's containing localBorderBoxProperties only. I think we can land the first optimization first, then consider step 2 to further reduce the number.

Will moving localBorderBoxProperties into PaintLayer look good? Or should we avoid any new PaintLayer dependencies?

Comment 4 by pdr@chromium.org, Mar 13 2017

Those numbers look great! hasLayer is sort of like checking LayoutBox::layerTypeRequired() so I think we could land the approach in your patch but add a TODO to replace the hasLayer check with a check of all of the properties in PaintPropertyTreeBuilder (i.e., style.hasTransform() || style.preserves3d() || ...)

Comment 5 by pdr@chromium.org, Mar 13 2017

I listed this as a P1 because it seems very likely to affect spinvalidation. Can you check how your first patch affects performance? We can use that to prioritize whether the second optimization approach is high priority or not.
In one of my previous profiling results, updateLocalBorderBoxContext() was not listed because it's smaller than the threshold, while updateTransform (0.7%) was listed. In that result, updatePropertiesForSelf was 4.17%. Based on that, I think the performance improvement will be likely below 1%. Anyway the optimization will reduce memory usage and improve cache locality. Let's look at the performance results on bots.


Status: Fixed (was: Assigned)

Comment 9 by pdr@chromium.org, Mar 28 2017

I think this is still a significant problem. I put together a patch to measure the total memory usage (https://codereview.chromium.org/2766943002) and found the following results:
https://docs.google.com/spreadsheets/d/1IC1JI0sX7QsR9FmA4G1-F9E_c3xRKDNoV3SkDKQ822U/view

I'm not 100% sure the heap memory calculation is correct in my patch, but it seems to be in the correct ballpark. This data shows that slimming paint invalidation adds 312k to a youtube video, primarily because of local border box properties.

Comment 10 by pdr@chromium.org, Mar 29 2017

Owner: pdr@chromium.org
Status: Started (was: Fixed)
I'm going to look at moving LocalBorderBoxProperties.
Project Member

Comment 11 by bugdroid1@chromium.org, Mar 30 2017

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

commit 7f0d97dcab059b98a6825ee172c7140ff938f667
Author: pdr <pdr@chromium.org>
Date: Thu Mar 30 21:29:35 2017

Add LayoutObject::RarePaintData for rare paint data

This patch adds a rare data struct to LayoutObject for paint-related
data. In this patch we just use it for ObjectPaintProperties, but this
sets the groundwork for splitting LocalBorderBoxProperties out of
ObjectPaintProperties so it can be managed independently. Data in
 crbug.com/700452  [1] shows that LayoutBorderBoxProperties is needed
much more than ObjectPaintProperties so this will save memory.

In addition, a future patch will use store PaintLayer in this rare
data, reducing one pointer from LayoutBoxModelObject.

[1] https://docs.google.com/spreadsheets/d/1IC1JI0sX7QsR9FmA4G1-F9E_c3xRKDNoV3SkDKQ822U

BUG= 700452 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

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

[modify] https://crrev.com/7f0d97dcab059b98a6825ee172c7140ff938f667/third_party/WebKit/Source/core/layout/LayoutObject.cpp
[modify] https://crrev.com/7f0d97dcab059b98a6825ee172c7140ff938f667/third_party/WebKit/Source/core/layout/LayoutObject.h

Project Member

Comment 12 by bugdroid1@chromium.org, Apr 2 2017

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

commit 4b973463f5203e58f12e363703026d6acb808026
Author: pdr <pdr@chromium.org>
Date: Sun Apr 02 05:57:33 2017

Store local border box property cache outside ObjectPaintProperties

This patch moves the local border box property cache out of
ObjectPaintProperties so it can be managed separately. Data in
 crbug.com/700452  [1] shows that LocalBorderBoxProperties is needed
much more than ObjectPaintProperties so this will save memory.

The big change here is to move LocalBorderBoxProperties from
ObjectPaintProperties to LayoutObject::RarePaintData. Because
the contents properties cache depends on the local border box
properties, it has also been moved to RarePaintData.

This patch reduces memory on youtube.com by 106.7KB [1].

[1] https://docs.google.com/spreadsheets/d/1IC1JI0sX7QsR9FmA4G1-F9E_c3xRKDNoV3SkDKQ822U

BUG= 700452 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

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

[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/frame/LocalFrame.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/layout/LayoutObject.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/layout/LayoutObject.h
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/FindPropertiesNeedingUpdate.h
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/ObjectPaintProperties.h
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PaintLayer.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
[modify] https://crrev.com/4b973463f5203e58f12e363703026d6acb808026/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp

Project Member

Comment 13 by bugdroid1@chromium.org, Apr 6 2017

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

commit d8c43f8e7d8c730a082122680008cdbf8b6ed43d
Author: pdr <pdr@chromium.org>
Date: Thu Apr 06 02:26:57 2017

Move RarePaintData to its own file

This patch pulls RarePaintData out of LayoutObject so the paint data
as it is only needed for paint things. This is just a refactoring
and should have no observable effect.

BUG= 700452 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

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

[modify] https://crrev.com/d8c43f8e7d8c730a082122680008cdbf8b6ed43d/third_party/WebKit/Source/core/layout/LayoutObject.cpp
[modify] https://crrev.com/d8c43f8e7d8c730a082122680008cdbf8b6ed43d/third_party/WebKit/Source/core/layout/LayoutObject.h
[modify] https://crrev.com/d8c43f8e7d8c730a082122680008cdbf8b6ed43d/third_party/WebKit/Source/core/paint/BUILD.gn
[delete] https://crrev.com/08edaf185f52af495778ce04d7f28c781031dc66/third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp
[modify] https://crrev.com/d8c43f8e7d8c730a082122680008cdbf8b6ed43d/third_party/WebKit/Source/core/paint/ObjectPaintProperties.h
[add] https://crrev.com/d8c43f8e7d8c730a082122680008cdbf8b6ed43d/third_party/WebKit/Source/core/paint/RarePaintData.cpp
[add] https://crrev.com/d8c43f8e7d8c730a082122680008cdbf8b6ed43d/third_party/WebKit/Source/core/paint/RarePaintData.h

Project Member

Comment 14 by bugdroid1@chromium.org, Apr 10 2017

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

commit 4389ecfd97b746892b3ec0d85137e9f62b69ba3a
Author: pdr <pdr@chromium.org>
Date: Mon Apr 10 23:06:56 2017

Remove caching of contents paint properties

This patch stops caching contents paint properties which are rare
and take up a pointer on RarePaintData[1]. With this patch the
contents properties are recomputed from the local border box
properties as-needed.

[1] https://docs.google.com/spreadsheets/d/1IC1JI0sX7QsR9FmA4G1-F9E_c3xRKDNoV3SkDKQ822U/edit#gid=0

BUG= 700452 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

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

[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/layout/LayoutObject.h
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/paint/FindPropertiesNeedingUpdate.h
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/paint/RarePaintData.cpp
[modify] https://crrev.com/4389ecfd97b746892b3ec0d85137e9f62b69ba3a/third_party/WebKit/Source/core/paint/RarePaintData.h

Project Member

Comment 15 by bugdroid1@chromium.org, Apr 12 2017

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

commit 782b87888ae14a5531d8c248fb2c3337dc638e04
Author: pdr <pdr@chromium.org>
Date: Wed Apr 12 01:46:57 2017

Move LayoutBoxModelObject's PaintLayer member to rare paint data

This patch removes the PaintLayer member from LayoutBoxModelObject and
puts it in RarePaintData. This will save one pointer of memory and in
the common case RarePaintData will already exist.

Two minor cleanups have been included:
1) LayoutBoxModelObject::DestroyLayer has been changed to only get called
when a layer exists.
2) LayoutBoxModelObject::CreateLayer has been refactored to work more like
DestroyLayer. Instead of doing insert/remove logic in this function, the
caller is now responsible (InsertOnlyThisLayerAfterStyleChange).

BUG= 700452 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

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

[modify] https://crrev.com/782b87888ae14a5531d8c248fb2c3337dc638e04/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
[modify] https://crrev.com/782b87888ae14a5531d8c248fb2c3337dc638e04/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.h
[modify] https://crrev.com/782b87888ae14a5531d8c248fb2c3337dc638e04/third_party/WebKit/Source/core/layout/LayoutObject.h
[modify] https://crrev.com/782b87888ae14a5531d8c248fb2c3337dc638e04/third_party/WebKit/Source/core/paint/RarePaintData.cpp
[modify] https://crrev.com/782b87888ae14a5531d8c248fb2c3337dc638e04/third_party/WebKit/Source/core/paint/RarePaintData.h

Comment 16 by pdr@chromium.org, Apr 12 2017

Status: Fixed (was: Started)
Woohoo!

Sign in to add a comment