Closed Bug 1669520 Opened 5 years ago Closed 5 years ago

SWGL: https://nos.nl/ runs 4x slower than basic

Categories

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

defect

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox83 --- disabled

People

(Reporter: jrmuizel, Assigned: bradwerth)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached file Reduced tests case
Depends on: 1621454
Severity: -- → S4
Priority: -- → P3

Here are the timings for a frame of the reduced test case:

draw(cs_clip_rectangle, 1): 1.000000ms for 102400 pixels in 40 rows (avg 2560.000000 pixels/row, 9.765625ns/pixel)
draw(cs_clip_rectangle_FAST_PATH, 8): 0.000000ms for 2292 pixels in 94 rows (avg 24.382979 pixels/row, 0.000000ns/pixel)
draw(cs_clip_box_shadow, 20): 0.000000ms for 20586 pixels in 118 rows (avg 174.457627 pixels/row, 0.000000ns/pixel)
draw(cs_clip_image, 1): 0.000000ms for 2988 pixels in 18 rows (avg 166.000000 pixels/row, 0.000000ns/pixel)
draw(cs_clip_rectangle_FAST_PATH, 4): 0.000000ms for 16 pixels in 8 rows (avg 2.000000 pixels/row, 0.000000ns/pixel)
draw(brush_image_ALPHA_PASS, 1): 7.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 10.127315ns/pixel)
draw(brush_image_ALPHA_PASS, 2): 7.000000ms for 691456 pixels in 556 rows (avg 1243.625899 pixels/row, 10.123565ns/pixel)
draw(ps_text_run_ALPHA_PASS, 54): 0.000000ms for 1221 pixels in 193 rows (avg 6.326425 pixels/row, 0.000000ns/pixel)
draw(ps_text_run_ALPHA_PASS, 1): 0.000000ms for 0 pixels in 0 rows (avg -nan(ind) pixels/row, 0.000000ns/pixel)
draw(brush_image, 1): 6.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 8.680556ns/pixel)
draw(brush_image, 1): 6.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 8.680556ns/pixel)
draw(brush_solid, 13): 1.000000ms for 16952352 pixels in 6712 rows (avg 2525.678188 pixels/row, 0.058989ns/pixel)
draw(brush_image_ALPHA_PASS, 1): 0.000000ms for 2560 pixels in 1 rows (avg 2560.000000 pixels/row, 0.000000ns/pixel)
draw(brush_image_ALPHA_PASS, 1): 1.000000ms for 104960 pixels in 41 rows (avg 2560.000000 pixels/row, 9.527439ns/pixel)
draw(brush_image_ALPHA_PASS, 1): 0.000000ms for 256 pixels in 16 rows (avg 16.000000 pixels/row, 0.000000ns/pixel)
draw(brush_solid_ALPHA_PASS, 1): 0.000000ms for 102400 pixels in 40 rows (avg 2560.000000 pixels/row, 0.000000ns/pixel)
draw(brush_image_ALPHA_PASS, 6): 0.000000ms for 2808 pixels in 116 rows (avg 24.206897 pixels/row, 0.000000ns/pixel)
draw(brush_opacity_ALPHA_PASS, 3): 13.000000ms for 1382656 pixels in 1096 rows (avg 1261.547445 pixels/row, 9.402194ns/pixel)
draw(brush_solid_ALPHA_PASS, 25): 0.000000ms for 21614 pixels in 154 rows (avg 140.350649 pixels/row, 0.000000ns/pixel)
draw(brush_image_ALPHA_PASS, 29): 0.000000ms for 9667 pixels in 421 rows (avg 22.961995 pixels/row, 0.000000ns/pixel)
draw(ps_text_run_ALPHA_PASS_DUAL_SOURCE_BLENDING, 61): 0.000000ms for 3619 pixels in 518 rows (avg 6.986486 pixels/row, 0.000000ns/pixel)
draw(ps_text_run_ALPHA_PASS_DUAL_SOURCE_BLENDING, 2): 0.000000ms for 136 pixels in 17 rows (avg 8.000000 pixels/row, 0.000000ns/pixel)
draw(ps_text_run_ALPHA_PASS, 128): 1.000000ms for 47131 pixels in 2726 rows (avg 17.289435 pixels/row, 21.217458ns/pixel)
draw(brush_image_ALPHA_PASS, 1): 0.000000ms for 2988 pixels in 18 rows (avg 166.000000 pixels/row, 0.000000ns/pixel)

5 draw calls stand out:
I'm not sure what these are doing:

draw(brush_image_ALPHA_PASS, 1): 7.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 10.127315ns/pixel)
draw(brush_image_ALPHA_PASS, 2): 7.000000ms for 691456 pixels in 556 rows (avg 1243.625899 pixels/row, 10.123565ns/pixel)

These are the two main images:

draw(brush_image, 1): 6.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 8.680556ns/pixel)
draw(brush_image, 1): 6.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 8.680556ns/pixel)

This looks like the opacity on the gradient:

draw(brush_opacity_ALPHA_PASS, 3): 13.000000ms for 1382656 pixels in 1096 rows (avg 1261.547445 pixels/row, 9.402194ns/pixel)
Depends on: sw-wr-perf-opacity
Depends on: sw-wr-perf-nearest

These are us drawing the gradients into a temporary so that we can apply the opacity.

draw(brush_image_ALPHA_PASS, 1): 7.000000ms for 691200 pixels in 540 rows (avg 1280.000000 pixels/row, 10.127315ns/pixel)
draw(brush_image_ALPHA_PASS, 2): 7.000000ms for 691456 pixels in 556 rows (avg 1243.625899 pixels/row, 10.123565ns/pixel)

Bug 1669840 should help us avoid this.

The fast paths improved performance significantly. Frame times went from 90-100ms to 35ms.
https://share.firefox.dev/35Rj3EH

brush_opacity went from 30% to 10%: https://share.firefox.dev/2XHHFvM with frame times of around 22ms

Edit The timings below were taken from a capture with the patches from Bug 1669840 applied. That means this issue is still occurring and that the patches do provide a remedy.


I am trying to replicate this bug using the reduced testcase and I'm not getting the same brushes used in playback:

  2.013ms draw(brush_image_TEXTURE_2D, 1): 397312 pixels in 388 rows (avg 1024.000000 pixels/row, 5.065827ns/pixel)
  2.205ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 397312 pixels in 388 rows (avg 1024.000000 pixels/row, 5.550900ns/pixel)
  0.798ms draw(brush_image_TEXTURE_2D, 1): 126876 pixels in 388 rows (avg 327.000000 pixels/row, 6.292884ns/pixel)
  1.338ms draw(brush_image_TEXTURE_2D, 1): 270436 pixels in 388 rows (avg 697.000000 pixels/row, 4.949197ns/pixel)
  2.175ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 2): 397312 pixels in 776 rows (avg 512.000000 pixels/row, 5.474725ns/pixel)
  1.232ms draw(brush_image_TEXTURE_2D, 1): 253752 pixels in 388 rows (avg 654.000000 pixels/row, 4.854626ns/pixel)
  1.394ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 253752 pixels in 388 rows (avg 654.000000 pixels/row, 5.494104ns/pixel)
  1.634ms draw(brush_image_TEXTURE_2D, 1): 354304 pixels in 346 rows (avg 1024.000000 pixels/row, 4.611356ns/pixel)
  1.844ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 354304 pixels in 346 rows (avg 1024.000000 pixels/row, 5.204367ns/pixel)
  1.719ms draw(brush_image_TEXTURE_2D, 1): 113142 pixels in 346 rows (avg 327.000000 pixels/row, 15.191008ns/pixel)
  1.130ms draw(brush_image_TEXTURE_2D, 1): 241162 pixels in 346 rows (avg 697.000000 pixels/row, 4.684129ns/pixel)
  2.143ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 2): 354304 pixels in 692 rows (avg 512.000000 pixels/row, 6.049754ns/pixel)
  1.064ms draw(brush_image_TEXTURE_2D, 1): 226284 pixels in 346 rows (avg 654.000000 pixels/row, 4.703452ns/pixel)
  1.184ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 226284 pixels in 346 rows (avg 654.000000 pixels/row, 5.232199ns/pixel)
 12.015ms draw(composite_TEXTURE_2D, 4): 1055744 pixels in 1216 rows (avg 868.210526 pixels/row, 11.380707ns/pixel)
  6.313ms draw(composite_TEXTURE_2D, 1): 334848 pixels in 512 rows (avg 654.000000 pixels/row, 18.851909ns/pixel)
  2.874ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 5.481737ns/pixel)
  4.224ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 8.056816ns/pixel)
  2.950ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 5.627359ns/pixel)
  6.366ms draw(composite_TEXTURE_2D, 1): 334848 pixels in 512 rows (avg 654.000000 pixels/row, 19.011265ns/pixel)
  0.436ms draw(composite_TEXTURE_2D, 1): 62784 pixels in 96 rows (avg 654.000000 pixels/row, 6.946913ns/pixel)
  3.839ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 7.321936ns/pixel)
  2.853ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 5.441410ns/pixel)

brush_opacity_ALPHA_PASS doesn't appear, but the first composite_TEXTURE_2D seems kind of slow at 12ms. Is this still a performance hit? If so, is Bug 1669840 still likely to provide a benefit?

Flags: needinfo?(jmuizelaar)

The composite_TEXTURE_2D calls are caused by us not using the software compositor in wrench. You should be able to just ignore them.

Flags: needinfo?(jmuizelaar)

Ah, I made a mistake in comment 6 (now edited). That capture was made with the patches from Bug 1669840 applied. The timings there indicate that those patches are effective in this testcase.

Updated profile:
https://share.firefox.dev/3oVtXAP

This is with 20210206094243 which should include bug 1669840. However, I'm still seeing time spent in brush_opacity_ALPHA.

Brad, do you see the same?

Flags: needinfo?(bwerth)

(In reply to Jeff Muizelaar [:jrmuizel] from comment #9)

Updated profile:
https://share.firefox.dev/3oVtXAP

This is with 20210206094243 which should include bug 1669840. However, I'm still seeing time spent in brush_opacity_ALPHA.

Brad, do you see the same?

I do not. Here's my timings from Wrench:

  1.837ms draw(brush_image_TEXTURE_2D, 1): 397312 pixels in 388 rows (avg 1024.000000 pixels/row, 4.622604ns/pixel)
  2.148ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 397312 pixels in 388 rows (avg 1024.000000 pixels/row, 5.406029ns/pixel)
  2.060ms draw(brush_image_TEXTURE_2D, 1): 270436 pixels in 388 rows (avg 697.000000 pixels/row, 7.616412ns/pixel)
  0.596ms draw(brush_image_TEXTURE_2D, 1): 126876 pixels in 388 rows (avg 327.000000 pixels/row, 4.696144ns/pixel)
  2.168ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 2): 397312 pixels in 776 rows (avg 512.000000 pixels/row, 5.457409ns/pixel)
  1.122ms draw(brush_image_TEXTURE_2D, 1): 253752 pixels in 388 rows (avg 654.000000 pixels/row, 4.421841ns/pixel)
  1.289ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 253752 pixels in 388 rows (avg 654.000000 pixels/row, 5.081493ns/pixel)
  2.053ms draw(brush_image_TEXTURE_2D, 1): 354304 pixels in 346 rows (avg 1024.000000 pixels/row, 5.795055ns/pixel)
  1.780ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 354304 pixels in 346 rows (avg 1024.000000 pixels/row, 5.024981ns/pixel)
  0.986ms draw(ps_text_run_ALPHA_PASS_TEXTURE_2D, 69): 71378 pixels in 2274 rows (avg 31.388742 pixels/row, 13.816078ns/pixel)
  1.650ms draw(brush_image_TEXTURE_2D, 1): 241162 pixels in 346 rows (avg 697.000000 pixels/row, 6.839908ns/pixel)
  0.505ms draw(brush_image_TEXTURE_2D, 1): 113142 pixels in 346 rows (avg 327.000000 pixels/row, 4.463206ns/pixel)
  1.828ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 2): 354304 pixels in 692 rows (avg 512.000000 pixels/row, 5.158641ns/pixel)
  1.139ms draw(ps_text_run_ALPHA_PASS_TEXTURE_2D, 108): 81818 pixels in 2614 rows (avg 31.299923 pixels/row, 13.917255ns/pixel)
  0.974ms draw(brush_image_TEXTURE_2D, 1): 226284 pixels in 346 rows (avg 654.000000 pixels/row, 4.304524ns/pixel)
  1.160ms draw(brush_image_ALPHA_PASS_TEXTURE_2D, 1): 226284 pixels in 346 rows (avg 654.000000 pixels/row, 5.126271ns/pixel)
  0.245ms draw(ps_text_run_ALPHA_PASS_TEXTURE_2D, 72): 16919 pixels in 569 rows (avg 29.734622 pixels/row, 14.452154ns/pixel)
 13.485ms draw(composite_TEXTURE_2D, 4): 1055744 pixels in 1216 rows (avg 868.210526 pixels/row, 12.773387ns/pixel)
  9.081ms draw(composite_TEXTURE_2D, 1): 334848 pixels in 512 rows (avg 654.000000 pixels/row, 27.118752ns/pixel)
  2.897ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 5.526304ns/pixel)
  3.937ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 7.508543ns/pixel)
  3.140ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 5.988636ns/pixel)
  6.639ms draw(composite_TEXTURE_2D, 1): 334848 pixels in 512 rows (avg 654.000000 pixels/row, 19.826393ns/pixel)
  0.494ms draw(composite_TEXTURE_2D, 1): 62784 pixels in 96 rows (avg 654.000000 pixels/row, 7.862784ns/pixel)
  4.219ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 8.046543ns/pixel)
  2.830ms draw(composite_TEXTURE_2D, 1): 524288 pixels in 512 rows (avg 1024.000000 pixels/row, 5.398529ns/pixel)
Finish
Flags: needinfo?(bwerth)

What if you profile it in the browser?

Flags: needinfo?(bwerth)

(In reply to Jeff Muizelaar [:jrmuizel] from comment #11)

What if you profile it in the browser?

I don't see it in a profile, either: https://share.firefox.dev/3phxf1x

Flags: needinfo?(bwerth)

(In reply to Brad Werth [:bradwerth] from comment #12)

(In reply to Jeff Muizelaar [:jrmuizel] from comment #11)

What if you profile it in the browser?

I don't see it in a profile, either: https://share.firefox.dev/3phxf1x

Sorry, I didn't realize that part of the Steps to Reproduce is to hover over the images. That does trigger the brush_opacity_ALPHA_PASS_frag shader. I'll keep looking at what is going on here.

Assignee: nobody → bwerth

A wrench capture of the testcase with hover activated on one of the images also does not show time spent in brush_opacity_ALPHA_PASS. This seems to indicate that the optimizations in Bug 1669840 are not applying to animated gradients.

(In reply to Brad Werth [:bradwerth] from comment #14)

A wrench capture of the testcase with hover activated on one of the images also does not show time spent in brush_opacity_ALPHA_PASS. This seems to indicate that the optimizations in Bug 1669840 are not applying to animated gradients.

Indeed, by modifying the testcase to extend the animation duration, it's possible to capture a frame mid-animation and replay it in wrench to see time spent in brush_opacity_ALPHA_PASS.

tl;dr this is mostly working as intended.

Okay, what appears to be happening is that the animated opacity change creates a nsDisplayOpacity display item, whose child is a single nsDisplayBackgroundImage display item. Statically, that would be a case we would want to avoid and Bug 1669840 accomplishes that. As an animated image, it's not necessarily desirable because WebRender may be managing the opacity in the compositor, using the fully-opaque image as a texture. That's overall more efficient, if WebRender has the image stored as a texture. That status isn't exposed to Gecko presently, which means that a solution to this edge case would involve either:

  1. Exposing WR texture cache status to Gecko for purposes of these types of optimizations.
  2. Adding optimizations within WR to ignore the nsDisplayOpacity item when the texture is available, and move the opacity value into the compositor processing.

Given that the possibility that achieving this gain is not guaranteed (since the texture might not be cached) and the complexity of the possible solutions, and the fact that opacity animations are typically of a short duration (as they are on this site), I'm closing this Bug as WONTFIX. Indeed, the slowness reported in this Bug is now only evident when rapidly moving the cursor between animated elements, and is not apparent in general navigation.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: