Closed Bug 1686244 (sw-wr-perf-linear-gradient) Opened 3 months ago Closed 2 months ago

sw-wr: nasdaq.com spends lots of time in linear gradients

Categories

(Core :: Graphics: WebRender, defect, P3)

defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox87 --- fixed
firefox88 --- fixed

People

(Reporter: jrmuizel, Assigned: lsalzman)

References

(Blocks 2 open bugs)

Details

(Keywords: perf-alert)

Crash Data

Attachments

(6 files)

Severity: -- → S3
Priority: -- → P3
Blocks: 1692070

For linear gradients, we are currently bottlenecked by looking up a gradient
table entry, doing interpolation, and converting to pixel formats for every
sample.

We can accelerate this by instead looking for contiguous segments of gradient
within the range of entries we need to sample and then interpolating these
as a single gradient. This also enables us to convert to relevant pixel formats
only when setting up this gradient, which greatly reduces the per-pixel processing
down to essentially a shift and add.

To enable this sort of crawling of the gradient table, the output gradients have
been modified such that each entry's step value will equal an adjacent entry's
step value if and only if they are from same gradient. We can ensure this by, in
the very rare case two segments of gradient have the same step, using the equivalent
of nextafter() to imperceptibly alter the value so that the invariant is maintained.

Assignee: nobody → lsalzman
Status: NEW → ASSIGNED
Alias: sw-wr-perf-linear-gradient

The same optimization of looking for merged linear gradients can also be
applied to radial gradients by solving the quadratic equation to check
how large a span we can process within a given merged span. This allows
us to save a bunch of table lookup and some other math in the inner loops.

Depends on D105716

Some sites use pixelated image-rendering and/or 1x1 images as color sources.
When we hit these, we fall off the fast-path. Try to handle at least some of
the cases we are finding in the wild.

Depends on D105858

Attachment #9204374 - Attachment description: Bug 1686244 - Accelerate some types of nearest filtering. r?jrmuizel → Bug 1686244 - Accelerate nearest repeat filtering. r?jrmuizel
Attachment #9204374 - Attachment description: Bug 1686244 - Accelerate nearest repeat filtering. r?jrmuizel → Bug 1686244 - Accelerate nearest repeat filtering in SWGL. r?jrmuizel
Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6e97ee33645a
Accelerate linear gradients in SWGL. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/395458ef80ae
Accelerate radial gradients in SWGL. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/01f66dc6aca4
Accelerate nearest repeat filtering in SWGL. r=jrmuizel
Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8f0413b1ad6f
Avoid zero offset in radial gradient. r=jgilbert

== Change summary for alert #28874 (as of Mon, 22 Feb 2021 21:15:19 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
197% rasterflood_gradient windows10-64-shippable-qr e10s stylo webrender-sw 455.50 -> 1,350.83
179% rasterflood_gradient linux64-shippable-qr e10s stylo webrender-sw 488.33 -> 1,363.50
161% rasterflood_gradient macosx1014-64-shippable-qr e10s stylo webrender-sw 408.08 -> 1,064.42

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=28874

Comment on attachment 9204505 [details]
Bug 1686244 - Avoid zero offset in radial gradient.

Beta/Release Uplift Approval Request

  • User impact if declined: Trying to do partial SW-WR rollout on Linux. Would like to avoid people reporting significant performance regressions months down the line.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Only impacts SW-WR/Linux. We can abort the rollout if unstable. Adequate time to deal with any bugs.
  • String changes made/needed:
Attachment #9204505 - Flags: approval-mozilla-beta?
Attachment #9204124 - Flags: approval-mozilla-beta?
Attachment #9204359 - Flags: approval-mozilla-beta?
Attachment #9204374 - Flags: approval-mozilla-beta?

Comment on attachment 9204124 [details]
Bug 1686244 - Accelerate linear gradients in SWGL. r?jrmuizel

Approved for 87.0b3.

Attachment #9204124 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9204359 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9204374 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9204505 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Blocks: 1674015
Blocks: 1673907
Blocks: 1674479
Blocks: 1668495

This just reorders some checks to fail against NaNs and also checks for finiteness.

Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7be47f00f8cf
Handle degenerate linear gradients. r=aosmond

Comment on attachment 9205247 [details]
Bug 1686244 - Handle degenerate linear gradients. r?aosmond

Beta/Release Uplift Approval Request

  • User impact if declined: Fixes potential crashes related to degenerate gradients we discovered in local mochitest runs.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Just a crash fix for the feature uplift here.
  • String changes made/needed:
Attachment #9205247 - Flags: approval-mozilla-beta?

Comment on attachment 9205247 [details]
Bug 1686244 - Handle degenerate linear gradients. r?aosmond

Approved for 87.0b4.

Attachment #9205247 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Duplicate of this bug: 1696420
Crash Signature: [@ commitRadialGradient<T>]
You need to log in before you can comment on or make changes to this bug.