High CPU usage on arale when running simple clients with animations

Bug #1599649 reported by Andrea Bernabei
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mir
Confirmed
Undecided
Unassigned
mir (Ubuntu)
Confirmed
Undecided
Unassigned
qtmir (Ubuntu)
Confirmed
Undecided
Unassigned
unity8 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

It seems that independently from which Mir server I use (mir_demo_server, qtmir-demo-shell, unity8) the CPU usage on Arale when running any simple client seems to be quite high.

My investigation started with a designer contacting me about
https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1431957
and
https://bugs.launchpad.net/ubuntu/+source/ubuntu-system-settings/+bug/1513450

Since the activity indicator visual has to be updated anyway, we were looking at the options we had to also make it less CPU consuming at the same time.

It turned out it's not a matter of how you render it, anything that causes redraw at 60fps will cause high cpu usage, here are the results I got:

Tools:
phablet-shell to run the commands
top to see cpu usage

Device:
Arale, rc-proposed r370

Setup:
clean flash + apt-get install qtmir-tests mir-demos
(qtmir-tests will remove qtmir-android, you'll have to reinstall it until https://bugs.launchpad.net/ubuntu/+source/qtmir/+bug/1599614 is fixed)

echo 806000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 806000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
and the same for cpu1 and cpu2 (after bringing them online by scrolling scopes)

Results:
=== Minimal Mir server + egltriangle demo ===
sudo su
stop lightdm
echo 2047 > /sys/class/backlight/lm3630_bled/brightness
sudo mir_demo_server_minimal --arw-file

(separate shell, phablet user)
mir_demo_client_egltriangle -m /tmp/mir_socket

1 CORE ONLINE
mir_demo_server: 12.5%
mir_demo_client: 11%

=== Mir demo server + egltriangle demo ===
sudo su
stop lightdm
echo 2047 > /sys/class/backlight/lm3630_bled/brightness
LD_PRELOAD=/lib/arm-linux-gnueabihf/libpthread.so.0 mir_demo_server --test-client /usr/bin/mir_demo_client_egltriangle

1 CORE ONLINE
mir demo server: 20%
mir_demo_client: 9%

=== Qt Mir demo shell + egltriangle demo ===
sudo su
stop lightdm
echo 2047 > /sys/class/backlight/lm3630_bled/brightness
cd /usr/share/qtmir/qtmir-demo-shell
MIR_SERVER_FILE=/tmp/mir_socket QT_QPA_PLATFORM=mirserver qmlscene ./qml-demo-shell.qml

(on a separate shell, phablet user)
MIR_SOCKET=/tmp/mir_socket QT_QPA_PLATFORM=ubuntumirclient sudo mir_demo_client_egltriangle -- --desktop_file_hint=dialer-app

1 to 2 CORES ONLINE (varying)
qmlscene (Mir server): 27.5% CPU
mir_demo_client: 10% CPU

=== Unity8 + test qml app ===
qmlscene test.qml --desktop_file_hint=dialer-app

2 CORES ONLINE
Unity8: 30%
qmlscene: 15%
USC: 10%

==== QML TEST FILE ====
import QtQuick 2.4
import Ubuntu.Components 1.3

Item {
    anchors.fill: parent

    /*AnimatedSprite {
        id: sprite
        width: 69
        height: 69
        source: "spinner-spritesheet.png"
        frameCount: 74
        frameSync: true
        frameWidth: 81
        frameHeight: 81
        loops: 100
    }*/

    /*ActivityIndicator {
        id: indicator
        running: true
    }*/

    Rectangle {
        id: rect
        width: 69
        height: 69
        color: "orange"

        /*RotationAnimation on rotation {
            loops: Animation.Infinite
            from: 0
            to: 360
        }*/

        /*NumberAnimation on x {
            loops: Animation.Infinite
            from: 0
            to: 360
        }*/

        XAnimator {
            target: rect;
            from: 0;
            to: 360;
            duration: 15000
            running: true
        }
    }

    Timer {
        interval: 10000
        running: true
        onTriggered: Qt.quit()
    }
}

Tags: performance
Andrea Bernabei (faenil)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mir (Ubuntu):
status: New → Confirmed
Changed in qtmir (Ubuntu):
status: New → Confirmed
Changed in unity8 (Ubuntu):
status: New → Confirmed
tags: added: performance
summary: - High CPU usage when running simple clients with animations
+ High CPU usage on arale when running simple clients with animations
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Two things worth noting:

1. arale performance is quite poor, and we've known this for a long time. I mean the device itself. Its frequency governor keeps clock speeds so low for so long what frame rates rarely appear smooth (see bug 1488386). This is however a bug in the arale kernel drivers and not a bug in Mir or Unity8 that we can easily work around.

2. Are you sure 20-30% counts as high or a bug on this particular device? CPU usage varies wildly between graphics drivers and sometimes high CPU for constantly rendering is unavoidable. A good example is desktop -- you will find the Intel graphics driver uses very little CPU whereas Nvidia will use large amounts of CPU. Whether this is a bug or a feature that allows the driver to improve performance internally is not a question we can easily answer.

I'm not sure this is a Mir bug at all, or something we can improve in the above components at least.

Changed in mir:
status: New → Incomplete
Changed in mir (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Andrea Bernabei (faenil) wrote :

Hi Daniel,

I think it is something we should have a look at. You marked the bug as Incomplete, but I'm afraid I can't provide the info you're looking for, how would I know if that amount of CPU is high or low for this device with those drivers?

It sounds high to me, and consulting people in #unity and #mir I reported this bug to get the investigation started :)

Please note that there is also https://bugs.launchpad.net/ubuntu/+source/ubuntu-system-settings/+bug/1513450 that describes a similar situation but on Nexus 4 (40% cpu usage, although the clock speed is not stated there) and both this and that bug started from the same point, i.e. showing a spinner takes 40% CPU

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

I completely agree any CPU usage should be investigated. However you should not open a bug for CPU usage unless:

(a) It's near 100%; or

(b) It used to be lower but recently became higher; or

(c) Someone has spent the time with a profiler to identify where the CPU time is being spent and concluded it could be less.

Any of those three will suffice. In the mean time you don't need to provide further information. 'Incomplete' will allow the bug to expire in 60 days if we can't get a clearer picture.

Changed in qtmir:
status: New → Incomplete
Changed in qtmir (Ubuntu):
status: Confirmed → Incomplete
Changed in unity8 (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Andrea Bernabei (faenil) wrote :

I'm just afraid setting it to Incomplete means nobody will ever start the investigation...

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for unity8 (Ubuntu) because there has been no activity for 60 days.]

Changed in unity8 (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Mir because there has been no activity for 60 days.]

Changed in mir:
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for qtmir (Ubuntu) because there has been no activity for 60 days.]

Changed in qtmir (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for mir (Ubuntu) because there has been no activity for 60 days.]

Changed in mir (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for QtMir because there has been no activity for 60 days.]

Changed in qtmir:
status: Incomplete → Expired
Andrea Bernabei (faenil)
Changed in mir:
status: Expired → Confirmed
Changed in qtmir:
status: Expired → Confirmed
Changed in unity8 (Ubuntu):
status: Expired → Confirmed
Changed in mir (Ubuntu):
status: Expired → Confirmed
Changed in qtmir (Ubuntu):
status: Expired → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This is possibly not a bug at all, unless someone can prove arale can or has performed better than this in the past.

See comment #4 and #6, but also keep in mind arale has around 8 cores and still underperforms compared to other phones. So it stands to reason that even 100% of one core possibly isn't much to worry about if this is one of those platforms where the GPU load affects the CPU load.

I completely agree that anything above 1% I would recommend investigating, /if this was not a graphics problem/. However since it is a graphics problem it is reasonably likely that the high relative CPU load is due to graphics drivers and poor CPU scaling that is specific to arale (a known problem).

Since there is so much reasonable doubt as to whether this problem is in userspace at all, I recommend keeping it Incomplete unless we can get profile data showing high CPU in places where it shouldn't be.

Michał Sawicz (saviq)
no longer affects: qtmir
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.