Closed Bug 1647520 Opened 5 years ago Closed 5 years ago

Maybe stop searching for optimal column balancing block-size within a certain threshold

Categories

(Core :: Layout: Columns, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

Details

(Keywords: perf-alert)

Attachments

(4 files)

heycam has another idea to improve the column balancing performance. That is, we can stop searching for the optimal block-size once the difference of infeasible and feasible block-size is within a device pixel. Currently, we stop when the difference is within an app unit. [1]

This can save us a few final balancing iterations, and the slightly imperfect balance block-size shouldn't matter too much in practice.

However, we might need to fix some testcases where it's perfect balancing block-size is not divisible by device pixels like [2]

[1] https://searchfox.org/mozilla-central/rev/3d39d3b7dd1b2be30692d4541ea681614e34c786/layout/generic/nsColumnSetFrame.cpp#1046-1049
[2] https://searchfox.org/mozilla-central/rev/3d39d3b7dd1b2be30692d4541ea681614e34c786/layout/reftests/columns/column-balancing-overflow-005.html

  • floats-clear-multicol-balancing-*:

Change border-width from "normal" to "5px" so that the optimal column
height is 85px. This also makes those reftests renders the same across
all browsers since each browser renders "normal" differently.

  • column-balancing-overflow-005:

This test is already wrong as its height is 13px/3 = 4.3333px, so it can
pass with some fuzzy. This patch makes the target column height
4px (including the children's overflow). This is the same as the <p>'s
height 4px in reference file.

  • box-decoration-break-border-image:

Add 1px to .vbreak so that the optimal column balancing height is a
integer. Also, remove a whitespace between two <span> in <pos2> to make the
test more robust because the width of the whitespace is not an integer.

Without setting font and line-height, these reftests may yield different
results on different platforms because of the default font are
different. Also, their optimal column balancing height may not be an
integer CSS pixels.

I discover this because they are failing due to 1px column height
difference after we stop searching optimal balancing height within a
certain threshold on either macOS, Windows, or Android.

Depends on D83729

Here's an example that can break the loop at the first iteration.
<div style="column-count:2; height:100px"><img src="" style="height:500px">

Depends on D83730

The gist of this patch is: once the feasible and infeasible block-size
is within one device pixel, we choose nextGuess to be the greatest
multiple of one device pixel below or equal to the feasible block-size.
If this nextGuess is infeasible, we will reflow children one last time
by using the last feasible block-size and done with the balancing.

Depends on D83731

Assignee: nobody → aethanyc
Status: NEW → ASSIGNED

Here's a try result with my current patches. I see 8% ~ 16% performance improvement on Wikipedia. (Type "wikipedia" into the filter text box, and choose "Show only important changes" button)

https://treeherder.mozilla.org/perf.html#/compare?originalProject=mozilla-central&newProject=try&newRevision=d407abc829825db2185451148fdffe5343c14915&framework=10&selectedTimeRange=172800

Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/743486fcc01e Part 1 - Adjust reftests so that the optimal column balancing height is on whole CSS pixels. r=heycam https://hg.mozilla.org/integration/autoland/rev/a6b19393adea Part 2 - Set font and line-height to make column reftests stable across all platforms. r=heycam https://hg.mozilla.org/integration/autoland/rev/d6ce5fef610a Part 3 - Improve some comments in FindBestBalanceBSize(). r=heycam https://hg.mozilla.org/integration/autoland/rev/19047c90effa Part 4 - Stop binary search once the feasible and infeasible block-size is within one device pixel. r=heycam
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/24672 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot

== Change summary for alert #26571 (as of Wed, 22 Jul 2020 19:38:19 GMT) ==

Improvements:

10% raptor-tp6-wikipedia-firefox-cold loadtime windows10-64-shippable opt 1,893.08 -> 1,704.25
10% raptor-tp6-wikipedia-firefox-cold loadtime windows7-32-shippable opt 1,948.25 -> 1,758.50
8% raptor-tp6-wikipedia-firefox-cold loadtime windows10-64-shippable-qr opt webrender 1,823.67 -> 1,683.00
7% raptor-tp6-wikipedia-firefox-cold windows10-64-shippable opt 1,651.02 -> 1,527.99
7% raptor-tp6-wikipedia-firefox-cold windows7-32-shippable opt 1,681.69 -> 1,564.29
7% raptor-tp6-wikipedia-firefox-cold fcp windows10-64-shippable opt 1,588.83 -> 1,483.00
6% raptor-tp6-wikipedia-firefox-cold fcp windows7-32-shippable opt 1,614.42 -> 1,516.00
6% raptor-tp6-wikipedia-firefox-cold windows10-64-shippable-qr opt webrender 1,639.58 -> 1,542.67
5% raptor-tp6-wikipedia-firefox-cold fcp linux64-shippable-qr opt webrender 2,041.83 -> 1,935.33

For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=26571

Keywords: perf-alert
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: