Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User dynamic clock levels on Oculus #1062

Merged
merged 2 commits into from Apr 10, 2019
Merged

Conversation

MortimerGoro
Copy link
Contributor

@MortimerGoro MortimerGoro commented Apr 5, 2019

According to the Oculus docs the clock levels are a baseline, so even setting them to 2 the system can decide to increase them. However, we think something with their throttler is just wrong since with video perf we saw better performance at 4 than 2. If it were dynamic that should not be the case. On #947 some tests performed faster with cpu levels set to 4 than 2.

This PR sets the clock levels to 2 by default, and switches to 4 during WebVR and video playback. The benefit should be saving battery when we are not in WebVR and playing videos. Oculus browser does the same thing (dynamic levels while browsing but max levels in WebVR). My concern is if it affects WebGL while not in WebVR.

Thoughts? Should we use dynamic or fixed clock levels to 4?

Note: We can use the same code in this PR to enable 72Hz in Oculus Go and setting it back to 60Hz during WebVR and video playback. I'm contacting Oculus to fix a bug. I'll update the PR when we get the solution (it seems a problem in their end according to the contact)

@bluemarvin
Copy link
Contributor

I would be curious how this affects battery usage. Is there an easy way to test this with the Oculus tools? Maybe the Snapdragon Profiler?

@@ -1028,5 +1036,6 @@ public void setCylinderDensity(final float aDensity) {
private native void setControllersVisibleNative(boolean aVisible);
private native void runCallbackNative(long aCallback);
private native void setCylinderDensityNative(float aDensity);
private native void setCPULevelNative(boolean aHighLevel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit I have is I would like to move away from using booleans as arguments as they can make the call site inscrutable without looking at the function implementation. I realize Java doesn't have any really good solutions for the JNI boundary but I sort of feel like the extra work to use integer constants helps improve code readability. @MortimerGoro What are your thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good practice. I'll update the PR.

@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Apr 8, 2019

I updated the PR to use a enum in the JNI<->Java binding.

I also did some profiling with Snapdragon Profiler.

Battery power with 4/4 Levels on the content feed page:
Captura de pantalla 2019-04-08 a las 15 54 51

Battery power with 2/2 Levels on the content feed page:
Captura de pantalla 2019-04-08 a las 15 52 13

So it seems like an improvement

@fernandojsg
Copy link

@MortimerGoro here you have this branch compared to the oculus_clock:

image

image
image
image

| HALLOVREEN                |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         20.20 |           18.52 |     1.68 |   9.05% |
| numStutterEvents          |        133.00 |          123.00 |    10.00 |   8.13% |
| totalRenderTime           |      24808.71 |        28152.35 |  3343.64 |  13.48% |
| cpuTime                   |      15752.85 |        17993.30 |  2240.45 |  14.22% |
| cpuIdleTime               |      10665.59 |        11275.37 |   609.79 |   5.72% |
| cpuIdlePerc               |         42.96 |           40.62 |     2.34 |   5.75% |
| pageLoadTime              |       2111.15 |         1745.97 |   365.18 |  20.92% |
| totalTime                 |      28823.92 |        31318.20 |  2494.28 |   8.65% |
| timeToFirstFrame          |       4015.21 |         3165.85 |   849.36 |  26.83% |
| fps                       |         21.55 |           20.56 |     0.99 |   4.83% |
| dt                        |         52.14 |           57.90 |     5.75 |  11.03% |
| cpu                       |         64.18 |           66.68 |     2.50 |   3.89% |
| drawCalls                 |         19.04 |           19.04 |     0.00 |   0.01% |
| useProgramCalls           |         13.81 |           13.81 |     0.00 |   0.01% |
| faces                     |      21564.47 |        21570.38 |     5.90 |   0.03% |
| vertices                  |      66613.42 |        66631.13 |    17.71 |   0.03% |
| bindTextures              |         23.97 |           23.96 |     0.01 |   0.04% |
|  |
| CUBES-3ECS                |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         46.82 |           38.72 |     8.10 |  20.91% |
| numStutterEvents          |         63.67 |          138.67 |    75.00 | 117.80% |
| totalRenderTime           |      10767.46 |        12920.97 |  2153.51 |  20.00% |
| cpuTime                   |       5971.89 |         6764.75 |   792.85 |  13.28% |
| cpuIdleTime               |       4658.52 |         6006.66 |  1348.14 |  28.94% |
| cpuIdlePerc               |         43.34 |           46.48 |     3.14 |   7.25% |
| pageLoadTime              |        448.55 |          265.33 |   183.22 |  69.05% |
| totalTime                 |      11700.19 |        13578.22 |  1878.03 |  16.05% |
| timeToFirstFrame          |        932.73 |          657.25 |   275.48 |  41.91% |
| fps                       |         48.23 |           39.72 |     8.51 |  21.41% |
| dt                        |         21.30 |           25.59 |     4.29 |  20.14% |
| cpu                       |         56.80 |           55.28 |     1.52 |   2.75% |
| drawCalls                 |        100.45 |          100.45 |        = |       = |
| useProgramCalls           |          0.00 |            0.00 |        = |       = |
| faces                     |       1193.35 |         1193.35 |        = |       = |
| vertices                  |       3640.06 |         3640.06 |        = |       = |
| bindTextures              |          0.00 |            0.00 |        = |       = |
|  |
| CUBES-AFRAME              |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         40.37 |           38.40 |     1.97 |   5.12% |
| numStutterEvents          |        123.33 |          155.67 |    32.33 |  26.22% |
| totalRenderTime           |      12518.40 |        13037.69 |   519.29 |   4.15% |
| cpuTime                   |       6626.91 |         7280.89 |   653.99 |   9.87% |
| cpuIdleTime               |       5808.74 |         5674.51 |   134.23 |   2.37% |
| cpuIdlePerc               |         45.88 |           43.48 |     2.40 |   5.53% |
| pageLoadTime              |       2643.25 |         2403.27 |   239.98 |   9.99% |
| totalTime                 |      15468.37 |        15634.93 |   166.55 |   1.08% |
| timeToFirstFrame          |       2949.97 |         2597.23 |   352.74 |  13.58% |
| fps                       |         41.22 |           38.89 |     2.33 |   5.99% |
| dt                        |         24.92 |           25.96 |     1.04 |   4.18% |
| cpu                       |         54.16 |           57.51 |     3.35 |   6.18% |
| drawCalls                 |        100.09 |          100.09 |        = |       = |
| useProgramCalls           |          0.00 |            0.00 |        = |       = |
| faces                     |          0.00 |            0.00 |        = |       = |
| vertices                  |       3627.38 |         3627.38 |        = |       = |
| bindTextures              |          0.00 |            0.00 |        = |       = |
|  |
| BALLSHOOTER               |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         37.42 |           45.09 |     7.66 |  20.48% |
| numStutterEvents          |        103.00 |          118.00 |    15.00 |  14.56% |
| totalRenderTime           |      14473.18 |        11096.01 |  3377.17 |  30.44% |
| cpuTime                   |       4833.00 |         4281.15 |   551.85 |  12.89% |
| cpuIdleTime               |       9477.69 |         6687.87 |  2789.83 |  41.71% |
| cpuIdlePerc               |         63.46 |           60.28 |     3.17 |   5.26% |
| pageLoadTime              |        706.31 |          611.30 |    95.01 |  15.54% |
| totalTime                 |      15568.63 |        12048.21 |  3520.41 |  29.22% |
| timeToFirstFrame          |       1095.45 |          952.21 |   143.24 |  15.04% |
| fps                       |         43.46 |           46.70 |     3.24 |   7.45% |
| dt                        |         28.68 |           21.98 |     6.70 |  30.46% |
| cpu                       |         39.93 |           39.47 |     0.45 |   1.15% |
| drawCalls                 |         28.80 |           28.80 |     0.00 |   0.02% |
| useProgramCalls           |          2.00 |            2.00 |        = |       = |
| faces                     |          0.00 |            0.00 |        = |       = |
| vertices                  |      26952.64 |        26948.16 |     4.48 |   0.02% |
| bindTextures              |          0.00 |            0.00 |        = |       = |
|  |
| PERFORMANCE_MATRICES      |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         34.46 |           31.06 |     3.39 |  10.92% |
| numStutterEvents          |        238.00 |          274.00 |    36.00 |  15.13% |
| totalRenderTime           |      29131.90 |        32220.43 |  3088.53 |  10.60% |
| cpuTime                   |      17946.21 |        19737.98 |  1791.77 |   9.98% |
| cpuIdleTime               |      11035.57 |        12336.45 |  1300.87 |  11.79% |
| cpuIdlePerc               |         37.88 |           38.26 |     0.38 |   1.00% |
| pageLoadTime              |       1107.09 |          950.23 |   156.86 |  16.51% |
| totalTime                 |      30420.11 |        33291.23 |  2871.12 |   9.44% |
| timeToFirstFrame          |       1288.21 |         1070.80 |   217.41 |  20.30% |
| fps                       |         35.07 |           31.39 |     3.68 |  11.72% |
| dt                        |         29.01 |           32.11 |     3.10 |  10.67% |
| cpu                       |         64.82 |           64.52 |     0.30 |   0.46% |
| drawCalls                 |          0.00 |            0.00 |        = |       = |
| useProgramCalls           |          0.00 |            0.00 |        = |       = |
| faces                     |          0.00 |            0.00 |        = |       = |
| vertices                  |          0.00 |            0.00 |        = |       = |
| bindTextures              |          0.00 |            0.00 |        = |       = |
|  |
| PERFORMANCE_ANIMATION     |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         12.88 |           12.33 |     0.56 |   4.51% |
| numStutterEvents          |         20.67 |           22.50 |     1.83 |   8.87% |
| totalRenderTime           |      38849.54 |        40621.38 |  1771.84 |   4.56% |
| cpuTime                   |      31296.83 |        33745.64 |  2448.81 |   7.82% |
| cpuIdleTime               |       7336.05 |         6671.53 |   664.52 |   9.96% |
| cpuIdlePerc               |         18.88 |           16.41 |     2.47 |  15.04% |
| pageLoadTime              |       5179.37 |         4972.68 |   206.69 |   4.16% |
| totalTime                 |      44271.34 |        45797.81 |  1526.47 |   3.45% |
| timeToFirstFrame          |       5421.80 |         5176.43 |   245.37 |   4.74% |
| fps                       |         13.06 |           12.71 |     0.35 |   2.76% |
| dt                        |         77.42 |           81.00 |     3.58 |   4.62% |
| cpu                       |         81.79 |           83.95 |     2.17 |   2.65% |
| drawCalls                 |        192.00 |          192.00 |        = |       = |
| useProgramCalls           |          5.00 |            5.00 |        = |       = |
| faces                     |      32372.00 |        32372.00 |        = |       = |
| vertices                  |      97280.00 |        97280.00 |        = |       = |
| bindTextures              |         40.00 |           40.00 |        = |       = |
|  |
| PERFORMANCE_PHYSICS       |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         33.63 |           29.74 |     3.89 |  13.08% |
| numStutterEvents          |         73.00 |          104.00 |    31.00 |  42.47% |
| totalRenderTime           |      15161.77 |        16830.46 |  1668.69 |  11.01% |
| cpuTime                   |       9432.15 |        10131.75 |   699.61 |   7.42% |
| cpuIdleTime               |       5574.66 |         6532.02 |   957.36 |  17.17% |
| cpuIdlePerc               |         36.47 |           38.79 |     2.31 |   6.34% |
| pageLoadTime              |       3096.30 |         3112.83 |    16.53 |   0.53% |
| totalTime                 |      18672.83 |        20284.94 |  1612.11 |   8.63% |
| timeToFirstFrame          |       3511.07 |         3454.48 |    56.59 |   1.64% |
| fps                       |         34.40 |           30.30 |     4.10 |  13.51% |
| dt                        |         30.07 |           33.39 |     3.32 |  11.04% |
| cpu                       |         65.99 |           63.24 |     2.75 |   4.35% |
| drawCalls                 |        100.99 |          100.99 |        = |       = |
| useProgramCalls           |          2.00 |            2.00 |        = |       = |
| faces                     |       1199.90 |         1199.90 |        = |       = |
| vertices                  |       5603.71 |         5603.71 |        = |       = |
| bindTextures              |          0.00 |            0.00 |        = |       = |
|  |
| PERFORMANCE_COMPLEX_MODEL |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         23.82 |           25.60 |     1.78 |   7.46% |
| numStutterEvents          |        139.00 |          118.00 |    21.00 |  17.80% |
| totalRenderTime           |      42006.93 |        39077.10 |  2929.83 |   7.50% |
| cpuTime                   |      27420.73 |        26263.79 |  1156.94 |   4.41% |
| cpuIdleTime               |      14040.31 |        12390.45 |  1649.86 |  13.32% |
| cpuIdlePerc               |         33.43 |           31.71 |     1.72 |   5.43% |
| pageLoadTime              |       7839.25 |         8079.70 |   240.45 |   3.07% |
| totalTime                 |      49990.31 |        47257.49 |  2732.82 |   5.78% |
| timeToFirstFrame          |       7983.38 |         8180.39 |   197.01 |   2.47% |
| fps                       |         24.27 |           26.10 |     1.83 |   7.53% |
| dt                        |         41.50 |           38.69 |     2.81 |   7.26% |
| cpu                       |         66.75 |           69.01 |     2.26 |   3.39% |
| drawCalls                 |         71.00 |           71.00 |        = |       = |
| useProgramCalls           |         11.00 |           11.00 |        = |       = |
| faces                     |     141802.00 |       141802.00 |        = |       = |
| vertices                  |     425406.00 |       425406.00 |        = |       = |
| bindTextures              |         21.00 |           21.00 |        = |       = |
|  |
| PERFORMANCE_WEBGL_RAW     |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |          2.79 |            3.03 |     0.23 |   8.36% |
| numStutterEvents          |         19.00 |            8.00 |    11.00 | 137.50% |
| totalRenderTime           |     179080.16 |       165263.66 | 13816.50 |   8.36% |
| cpuTime                   |     166224.16 |       156857.76 |  9366.40 |   5.97% |
| cpuIdleTime               |      12581.36 |         8143.56 |  4437.80 |  54.49% |
| cpuIdlePerc               |          7.03 |            4.93 |     2.10 |  42.57% |
| pageLoadTime              |       2759.12 |         3637.38 |   878.26 |  31.83% |
| totalTime                 |     182169.10 |       169400.28 | 12768.82 |   7.54% |
| timeToFirstFrame          |       3088.94 |         4136.62 |  1047.68 |  33.92% |
| fps                       |          2.95 |            3.11 |     0.16 |   5.59% |
| dt                        |        358.33 |          330.66 |    27.66 |   8.37% |
| cpu                       |         95.08 |           96.48 |     1.40 |   1.47% |
| drawCalls                 |       5000.00 |         5000.00 |        = |       = |
| useProgramCalls           |          0.00 |            0.00 |        = |       = |
| faces                     |    4835000.00 |      4835000.00 |        = |       = |
| vertices                  |   14505000.00 |     14505000.00 |        = |       = |
| bindTextures              |          0.00 |            0.00 |        = |       = |
|  |
| AQUARIUM                  |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |         10.06 |            9.05 |     1.02 |  11.24% |
| numStutterEvents          |         19.00 |            7.33 |    11.67 | 159.09% |
| totalRenderTime           |      49678.82 |        55274.74 |  5595.92 |  11.26% |
| cpuTime                   |      32459.66 |        44149.38 | 11689.72 |  36.01% |
| cpuIdleTime               |      16265.54 |         9967.53 |  6298.01 |  63.19% |
| cpuIdlePerc               |         32.74 |           18.03 |    14.71 |  81.59% |
| pageLoadTime              |       1162.20 |          825.01 |   337.19 |  40.87% |
| totalTime                 |      50909.08 |        56123.08 |  5214.00 |  10.24% |
| timeToFirstFrame          |       1230.26 |          848.34 |   381.92 |  45.02% |
| fps                       |         11.83 |            9.47 |     2.36 |  24.93% |
| dt                        |         97.65 |          108.45 |    10.81 |  11.07% |
| cpu                       |         79.36 |           84.45 |     5.08 |   6.40% |
| drawCalls                 |       1594.29 |         1585.74 |     8.55 |   0.54% |
| useProgramCalls           |         45.91 |           45.69 |     0.22 |   0.49% |
| faces                     |     100657.85 |       100117.08 |   540.77 |   0.54% |
| vertices                  |     301973.55 |       300351.23 |  1622.32 |   0.54% |
| bindTextures              |         83.23 |           82.98 |     0.25 |   0.30% |
|  |
| AFTERTHEFLOOD-VLQ         |
| COUNTER                   | OCULUS_CLOCK  | OCULUS_DYNAMIC  |      DIF |    DIF% |
| avgFps                    |          9.04 |            8.74 |     0.30 |   3.43% |
| numStutterEvents          |         86.00 |           80.00 |     6.00 |   7.50% |
| totalRenderTime           |      66406.20 |        68681.26 |  2275.06 |   3.43% |
| cpuTime                   |      45414.36 |        48495.98 |  3081.62 |   6.79% |
| cpuIdleTime               |      20367.72 |        19331.74 |  1035.98 |   5.36% |
| cpuIdlePerc               |         30.67 |           28.15 |     2.52 |   8.97% |
| pageLoadTime              |      23897.26 |        22249.40 |  1647.86 |   7.41% |
| totalTime                 |     104433.76 |       100634.48 |  3799.28 |   3.78% |
| timeToFirstFrame          |      38027.56 |        31953.22 |  6074.34 |  19.01% |
| fps                       |         14.42 |           13.06 |     1.36 |  10.43% |
| dt                        |        109.82 |          113.23 |     3.42 |   3.11% |
| cpu                       |         70.57 |           72.36 |     1.79 |   2.53% |
| drawCalls                 |        166.40 |          166.40 |        = |       = |
| useProgramCalls           |         86.11 |           86.11 |        = |       = |
| faces                     |     549157.90 |       549157.90 |        = |       = |
| vertices                  |    1647477.96 |      1647477.96 |        = |       = |
| bindTextures              |        356.62 |          356.62 |        = |       = |

@bluemarvin
Copy link
Contributor

@MortimerGoro looks like it needs to be rebased before landing.

@MortimerGoro MortimerGoro merged commit 8b05b8d into master Apr 10, 2019
@bluemarvin bluemarvin deleted the oculus_dynamic_clocks branch April 10, 2019 16:41
@cvan cvan modified the milestones: v1.1.4, v1.1.3 Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants