Mir

Frame rate is artificially low on Diamondville Intel Atom systems due to aggressive power management

Bug #1388490 reported by Daniel van Vugt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mir
Fix Released
Medium
Daniel van Vugt
mir (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Running a server and a few clients on an Atom N270 (requires vivid) is very stuttery and apparently limited to around 20 FPS.

However this limitation is a bug. Firstly I notice the system is still 70% idle according to top. And if I drag the mouse constantly over a surface or move a window constantly, the rendering (of everything) becomes perfectly smooth ~60 FPS. Also using --compositor-report=log on the Mir server shows the compositor render time even on this very weak machine is only 2.6ms.

So we have a scheduling problem and forcing re-compositing via input is working around it. Obviously the clients themselves are not able to wake up the compositor frequently enough to ensure new frames get scheduled. However if I wake up the compositor using demo-shell mouse gestures then all is fast and smooth.

This seems to be the same kind of scheduling problem also observed on higher-end systems when the compositor buffer pipeline is reduced --> bug 1377872

Related branches

description: updated
tags: added: performance
Changed in mir:
assignee: Daniel van Vugt (vanvugt) → nobody
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Workaround: Start an _additional_ client that is not sync'd to vblank (frame dropping):
  mir_demo_client_egltriangle -q -n -s 1x1 &

This speeds up compositing and all clients to the full frame rate. Just like bug 1377872 :)

description: updated
Changed in mir:
assignee: nobody → Cemil Azizoglu (cemil-azizoglu)
Changed in mir:
milestone: 0.9.0 → 0.10.0
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think this might be due to bug 1395421.

Changed in mir:
assignee: Cemil Azizoglu (cemil-azizoglu) → nobody
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Found the cause, and it's a familiar one.

The issue is this Intel N270 Atom is entering idle state C4 ("deeper sleep" mode) constantly to reduce power consumption. When it does this, it doesn't have enough power to render the screen smoothly.

Workaround:
Keep the CPU awake and in full-power mode. For example: $ while true ; do true; done

Fix:
Yes, I think it is actually possible to fix this in Mir and not mandate a kernel config change. The fix should be to utilize the "autosleep and wake locks" feature that was introduced in Linux kernel 3.5. So we should be able to strategically tell the kernel when not to go into deep sleep and provide us with enough power to render smooth graphics when we need it. The bad news is this is an upstream-Linux feature only, and it's different to what you will find in Android kernels.

http://kernelnewbies.org/Linux_3.5#head-e04ea6fe9005ea057124123d7834624cd445e124
https://lwn.net/Articles/479841/

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Tried implementing userland wakelocks. Doesn't seem to help and the system still enters deep sleep much too quickly, resulting in high wakeup latency and stuttering. But my branch is attached anyway.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Another workaround that does actually work: Add these to your kernel command line:

intel_idle.max_cstate=0 processor.max_cstate=0

Changed in mir:
milestone: 0.10.0 → none
summary: - Frame rate is artificially low on some systems
+ Frame rate is artificially low on some systems due to Intel C-States
Changed in mir:
importance: High → Medium
description: updated
summary: - Frame rate is artificially low on some systems due to Intel C-States
+ Frame rate is artificially low on older Intel Atom systems due to
+ aggressive power management
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: Frame rate is artificially low on older Intel Atom systems due to aggressive power management
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

^^^ The above fix seems to be in kernel 4.2. Probably worth trying.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Confirmed this bug still exists for the Atom N270 in Ubuntu 16.04 with kernel 4.4.0-22-generic:

[2016-05-19 14:39:21.020231] compositor: Display 0xb1a00470 averaged 22.836 FPS, 1.929 ms/frame, latency 40.633 ms, 23 frames over 1.007 sec, 0% bypassed
[2016-05-19 14:39:20.013544] perf: mir_demo_client_egltriangle: 19.92 FPS, render time 0.53ms, buffer lag 151.47ms (3 buffers)

The same workarounds per above still work to get graphics smooth again:

[2016-05-19 14:33:04.257168] compositor: Display 0xb1a00470 averaged 59.872 FPS, 1.948 ms/frame, latency 13.574 ms, 60 frames over 1.002 sec, 0% bypassed
[2016-05-19 14:33:04.124395] perf: mir_demo_client_egltriangle: 59.88 FPS, render time 0.44ms, buffer lag 49.68ms (3 buffers)

summary: - Frame rate is artificially low on older Intel Atom systems due to
+ Frame rate is artificially low on Diamondville Intel Atom systems due to
aggressive power management
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

A kernel fix for Atoms is on the way. Although the fix relates to P-states and the workaround used so far was to do with C-states. I hope it helps this bug somehow...

https://patchwork.kernel.org/patch/9364643/
https://lkml.org/lkml/2016/10/14/288

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Tested zesty (kernel 4.9) and sadly this bug is still present. Those P-state fixes in kernel 4.9 were not enough to fix the old Diamondville Atom.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think there's a chance this bug might get solved by lp:~vanvugt/mir/client-side-vsync since that enforces an exact wakeup time to start rendering at.

Can't easily test that right now unfortunately because building test branches for Diamondville (i386) is awkward. Maybe on the weekend.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Fixed! It's almost perfect using lp:~vanvugt/mir/client-side-vsync

Changed in mir:
assignee: nobody → Daniel van Vugt (vanvugt)
milestone: none → 1.0.0
status: Triaged → In Progress
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

Fix committed into lp:mir at revision None, scheduled for release in mir, milestone 1.0.0

Changed in mir:
status: In Progress → Fix Committed
Changed in mir:
milestone: 1.0.0 → 0.26.0
tags: added: atom
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (7.2 KiB)

This bug was fixed in the package mir - 0.26.0+17.04.20170126.3-0ubuntu1

---------------
mir (0.26.0+17.04.20170126.3-0ubuntu1) zesty; urgency=medium

  [ Daniel van Vugt ]
  * New upstream release 0.26.0 (https://launchpad.net/mir/+milestone/0.26.0)
    - ABI summary:
      . mirclient ABI unchanged at 9
      . mirserver ABI bumped to 43
      . mircommon ABI unchanged at 7
      . mirplatform ABI unchanged at 14
      . mirprotobuf ABI unchanged at 3
      . mirplatformgraphics ABI unchanged at 11
      . mirclientplatform ABI unchanged at 5
      . mirinputplatform ABI unchanged at 6
      . mircore ABI unchanged at 1
    - Enhancements:
      . New/improved toolkit APIs: MirInputConfig and related functions,
        MirWindow and related functions, DisplayConfig and related functions,
        MirScreencastSpec and related functions,
      . Support for configuring input configuration
      . Introduce toolkit extension mechanism for platform specific APIs.
      . Toolkit extensions for: mesa_drm_auth, set_gbm_device and
        window_coordinate_translation
      . Screencasting to a specific MirBuffer.
      . Add DisplayConfigurationController::base_configuration() so downstreams
        can get the base configuration. (Weirdly they can already set it.).
      . x11 platform: allow adjustable scale parameter.
      . Added EDID support: client API, server logging and in mirout.
      . mirout: Add newer attributes only available in the new display
        config API: scaling factor, subpixel arrangement and form factor.
      . mirout: Log the orientation and logical size of each output too.
      . Replace the mir::Server-overridable Reports with Observers.
      . Add xkbcommon to mirclient.pc Requires.private.
      . Deprecate legacy toolkit APIs that will be removed in Mir 1.0
      . Introduced 'client-side vsync', which dramatically reduces latency
        from the client to the screen (particularly for nested servers like
        Unity8).
    - Bugs fixed:
      . [performance] Restore support for better-than-triple buffering by
        default. (LP: #1240909)
      . Frame rate is artificially low on Diamondville Intel Atom systems due
        to aggressive power management (LP: #1388490)
      . [testsfail] failure in CI in
        AndroidInputReceiverSetup.slow_raw_input_doesnt_cause_frameskipping
        (LP: #1394369)
      . [trusted prompt sessions] Can't open two prompt sessions at the same
        time (LP: #1494197)
      . Changing scale, formFactor or DPI in display configuration causes
        renderer teardown/recreate unnecessarily (LP: #1556142)
      . [testsfail] ApplicationNotRespondingDetection.failure_to_pong_is_
        noticed (LP: #1570327)
      . CI failure in TestClientInput.receives_one_touch_event_per_frame
        (LP: #1570698)
      . Mir-on-X mouse input is jerky/stuttery compared to Mir-on-KMS
        (LP: #1576600)
      . [regression] Two fingers in mir_proving_server now resizes/moves app
        windows (two finger apps unusable) (LP: #1586311)
      . Pointer/cursor input lag in unity8 session (LP: #1591328)
      . PointerConfinement.test_we_update_our_confined_region_on_a_resize
      ...

Read more...

Changed in mir (Ubuntu):
status: New → Fix Released
Changed in mir:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.