New issue
Advanced search Search tips

Issue 922029 link

Starred by 1 user

Issue metadata

Status: ExternalDependency
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

GLSL/NVIDIA bug: dead code unrecognized + unrolled code 25 times more costly than loop

Reported by fabrice....@gmail.com, Jan 15

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

Example URL:
https://www.shadertoy.com/view/3slGWS

Steps to reproduce the problem:
See url.

* unrecognized dead code:
- call a costly function many times, don't use the result.
- See perfs. Compare perfs with calling the function in a loop.

* unrolling vs loop perf:
- Call a costly function many times. Compare perfs with calling the function in a loop.

NB: if you have a good GPU, you should duplicated unrolled lines and multiply loop accordingly to aim 30 fps.

What is the expected behavior?
- max fps when no result is used. ( final fragColor = vec4(0) ).
- about the same perf for loop and manually unrolled version (at least not a perf ratio of 25 ).

What went wrong?
* dead code not recognized:
- when replacing shader end by fragColor = vec4(0) the cost keeps mostly the same (while get to 60fps with the loop).

* perf difference with manual unrolling:
on my machine, 30 explicit calls to func cost as much as a loop of 800 (func does depend of loop invariant ).

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? Yes NVIDIA driver 384.130

Does this work in other browsers? No
 firefox

Chrome version: 71.0.3578.98  Channel: stable
OS Version: various ubuntu and Windows
Flash Version: 

May somebody please set the flags
Blink>WebGL
Internals>GPU>ANGLE 
? 
thanks !

Note that it is probably an NVIDIA driver bug, possibly due to the new Nvidia GLSL/SPIR-V compiler :

linux:
I *don't* have the bug on linux/nvidia with driver 384.130
I have the bug on linux/nvidia with driver  396.54
I have the bug on linux/nvidia with driver  390.77
I have the bug on linux/nvidia with driver 410.78

windows:
I *don't* have the bug on windows/nividia with both trueOpenGL and Angle mode with driver 375.86
I have the bug on windows/nvidia trueOpenGL Angle=off  with the ultra-last driver.
 
Labels: Needs-Bisect Needs-Triage-M71
Components: -Blink Blink>WebGL
Cc: kkinnu...@nvidia.com
Labels: -Pri-2 GPU-NVidia Pri-3
Status: Available (was: Unconfirmed)
Kimmo, do you think you could triage this?

Cc: phanindra.mandapaka@chromium.org
Labels: Triaged-ET Needs-Feedback
Thanks for filing the issue...

Tried to reproduce the issue on reported chrome version 71.0.3578.98 using Ubuntu 17.10 and Windows 10. Attaching screen-cast for reference.
Steps: 
------
1. Launched reported chrome 
2. Navigated the URL "https://www.shadertoy.com/view/3slGWS"
3. Ran the code as per attached screen-cast 
As we have observed that the fps is max 13.14

@Reporter: Could you please check the attached screencast and let us know if we missed anything from our end and if possible provide screencast for better understanding of the issue.

Thanks.!
922029.webm
3.1 MB View Download

Comment 6 by fabrice....@gmail.com, Jan 16 (6 days ago)

Thanks, but sorry, you didn't tested anything.
-> I rewrap below in more step by step details.

- prerequisite:  
    - nVidia GPU
    - recent drivers ( >= 396.54 )
    - either linux or trueOpenGL mode in windows.

- perfs measurements:
  - better if you let fps stabilize.
  - if too fast ( > 30fps ), edit the code to lengthen the loop + the unrolled version by a factor (2 or 4 or 8 if powerfull GPU). But seems ok as is for your GPU.


- bench set up:

  - line 17: #if triggers either the loop (case 1, default) or the explicit unrolling. lenghts are different on purpose (same cost on my machines).
    -> you will have to edit the code to try #if 1 and #if 0

  - line 25: outputting the result in fragColor (default) or commenting this line so as almost all code becomes dead code. 
    ->  you will have to edit the code for having the line either active or commented.


- showing the bug:   
  watch the perfs in the 4 combinations below:

  - default case ( line 17: #if 1  line 25: active )
     ~ 5-13fps in your case (would be better to stabilize, but clearly slow).

  - comment line 25:  the fps should jump to ~maxfps (deadcode eliminated)

  - restore line 25, + set #if 0 line 17.( now testing explicit unroll ).
    First anomaly: 30 explicit call of T cost ~as much as a loop of 800.

  - comment line 25:  the fps keeps low (almost not changing), despite the compiled code should be near empty: deadcode has not been detected.
Which is a serious regression, and optimization now probably bad in various cases.

thanks,

Comment 7 by kkinnu...@nvidia.com, Jan 16 (6 days ago)

Owner: kkinnu...@nvidia.com
Status: WontFix (was: Available)
Thanks for the report.
Yeah, the performance difference can be observed with Windows 416.34, GTX 1080. GPU utilization of 85% vs 100%. FPS does not saturate for me.

Likely this is not a Chromium issue, so probably it's not fully ok to assess this further here. There's no action for Chromium, so maybe it's better to close this one.

I moved the discussion to our public "bug tracker" at:
https://devtalk.nvidia.com/default/topic/1046314/opengl/bug-report-glsl-perf-dead-code-unrecognized-unrolled-code-25-times-more-costly-than-loop/

If I manage to create a non-browser repro and if that does not repro the problem, then we should revisit investigating this in WebGL/Chromium context.

Comment 8 by fabrice....@gmail.com, Jan 16 (6 days ago)

Usually there was an nVidia guy ( used to be Olli ) that either treat it directly or forward the bug report to an internal place at nVidia ( or Angle or else ).
Many bugs have been corrected that way.

One of the great thing here is that there are several key people from related community that can handle things through better place.

Note sure closing it so soon is good for that management to occurs.

Comment 9 by kkinnu...@nvidia.com, Jan 16 (6 days ago)

Owner: kbr@chromium.org
Yeah, I'll can treat it directly and forward the bug report to our internal tracker.
I just closed this one as it does not seem to be polite to use Chromium bug tracker as NV public bug tracker -- for me personally this is fine too. I'll let kbr@ deal with the closing :)

 I'd imagine logic wrt keeping a particular bug open here would be if there's 
a) a chromium workaround in the works 
b) the particular driver bug would block chromium test functionality, and such tracking the driver fix would result in Chromium related actions, such as enabling of the tests in Chromium.


Comment 10 by kkinnu...@nvidia.com, Jan 16 (6 days ago)

Status: Available (was: WontFix)

Comment 11 by kkinnu...@nvidia.com, Jan 16 (6 days ago)

Owner: ----

Comment 12 by fabrice....@gmail.com, Jan 16 (6 days ago)

I just wanted to be sure it would not end up sunk in the sands.
-> If you handle it, this is perfect ! (thanks !)

NB: this one bug seems to be a pure NV driver bug that probably must be tackled quickly at this level, but previous ones happened to be either more mix or easier to be tackled by Angle rewriting rules at short-mid term. 
More generally, webGL bugs are a mix of many levels not always easy to sort-out at first, or that might be turned-around at Angle level. So I guess it's not bad to at least keep the possibility to put here bug reports that are probably NV related, even if they can be triagged out to NV by you soon later ;-) .

thanks,

Comment 13 by kainino@chromium.org, Jan 16 (6 days ago)

Status: ExternalDependency (was: Available)

Sign in to add a comment