Author Topic: Aqua Mail doing well in terms of CPU consumption, but could do better  (Read 29596 times)

doctorow

  • Jr. Member
  • **
  • Posts: 87
I have been running some tests comparing Aqua Mail to Kaiten/K9 in terms of CPU consumption. With all scheduled syncs switched off and only relying on IMAP push, Aqua Mail generally consumes less CPU cycles than Kaiten does.  ;D

There is one exception, however. When all connectivity is switched of (aka flight mode), Kaiten/K9 uses almost no CPU cycles when in background, faring better than Aqua Mail. Not sure why that is, but perhaps some wakelocks could be temporarily disabled when no connectivity is detected.

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #1 on: December 04, 2012, 03:06:13 am »
What tool are you using to look at these stats?

My app tries to reconnect after the connection has been lost, but after that, it should be waiting for new connectivity events, and there really isn't anything to do in the background.

Just ran this scenario on a Galaxy Nexus, with "top" in the device's "adb shell" -- the retry takes something like 10ms, and the app is at 0% CPU otherwise....

So -- please clarify.

Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #2 on: December 04, 2012, 03:31:02 am »
Hi Kostya,

In terms of wakelocks / alarms, which are responsible for keeping a device awake, you can use the following (free) tool:

http://forum.xda-developers.com/showthread.php?t=1179809

(it's also available as a pay app on Google Market)

I used System Tuner Pro to track the CPU cycle usage over time:

https://play.google.com/store/apps/details?id=ccc71.pmw.pro&hl=en

I disable all connectivity and log app activity for the next 60 mins. For Aqua Mail I noticed occasional spikes in the CPU usage, indicating that it is doing something occasionally even as it is not receiving new connectivity events.

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #3 on: December 04, 2012, 06:06:03 am »
Attached you find two screenshots depicting the results of running both Kaiten/K9 and Aqua Mail for one hour in background with all connectivity switched off. Neither of the two apps were used in the time, the phone's display was switched off.

Given above scenario, Aqua Mail consumed .20s CPU cycles. In contrast, Kaiten consumed .08s CPU cycles. For both apps you can look at the charts how the cycle usage is distributed for each app.

I am sure there are better ways for an even more accurate analysis, like using Android's built-in debugging tools, but this gives you a quick picture.

Another important tool is BetterBatteryStats which I mentioned in the last post. It shows when and how often apps wake up the device from its sleep cycle. Generally Aqua Mail is behaving very fine here in comparison to other mail apps like K9, but I have noticed a few spikes in partial wakeups caused by Aqua Mail, and am still trying to find a way to reproduce them.

Cheers

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #4 on: December 05, 2012, 02:29:50 am »
The attached screenshot is from AquaMail Pro 1.2.0.5.1. I am not sure if this issue was present in earlier versions (I might be wrong but I thought earlier versions were OK), but here you see clearly that this there is something causing this version of AquaMail to consume a _large_ amount of time during partial wakelocks when the device is idle in deep sleep mode. In comparison you see Kaiten/K9 only consuming a fraction of time in wakelock. Both clients have the same account configured and use IMAP Idle to receive new mail (no scheduled mail checking).

You can read more about partial wakelocks here:


Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #5 on: December 07, 2012, 03:09:15 am »
What is your "messages per page" setting in my app?

This is how many messages the app looks at every time it checks mail. The default is a very conservative 25 (like in built-in Email and K-9, IIRC), using a high value here can make the app do much more work.
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #6 on: December 07, 2012, 04:46:18 am »
What is your "messages per page" setting in my app?

This is how many messages the app looks at every time it checks mail. The default is a very conservative 25 (like in built-in Email and K-9, IIRC), using a high value here can make the app do much more work.

I have set it to the default (25), same as K9. I don't really understand why it should matter actually, since I have scheduled mail checking turned off and only use IMAP IDLE.

Note the duration of the wakelocks in the screenshot. Even if you choose a higher number of messages per page, acquiring and using wakelocks for a duration of over one hour in less than a day while the device is supposed to be in deep sleep indicates that something is wrong.

I downgraded to Aqua Mail 1.2.0.4.10 because I don't remember seeing those high numbered and long-lasting wakelocks there. Will have to let it run for a while first to confirm.
« Last Edit: December 07, 2012, 04:49:37 am by doctorow »

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #7 on: December 07, 2012, 11:43:31 am »
I downgraded to Aqua Mail 1.2.0.4.10 because I don't remember seeing those high numbered and long-lasting wakelocks there. Will have to let it run for a while first to confirm.

Ok, had the phone on deep sleep for the last six hours and the result is how I remember it. Aqua Mail 1.2.0.4.10 only used 37 partial wakelocks and spent a total of 34 seconds during these locks. Huge difference to the results of the newer Aqua Mail posted above.

Update: Turned out after a few more hours suddenly the time for the held wakelocks increased dramatically, similar to 1.2.0.5.1.  :-[
« Last Edit: December 07, 2012, 03:51:16 pm by doctorow »

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #8 on: December 08, 2012, 03:15:29 am »
Yes, it does seem high.

Could you try collecting a debug log over a period of several hours?

http://www.aqua-mail.com/?page_id=232
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #9 on: December 08, 2012, 03:27:22 am »
Oh, forgot to ask.

What do you see in battery stats, as far as the actual battery consumption goes?

Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #10 on: December 08, 2012, 03:34:54 am »
Oh, forgot to ask.

What do you see in battery stats, as far as the actual battery consumption goes?

I haven't done any comprehensive battery comparisons. What the partial wakelock means is that during that time some function in Aqua Mail keeps certain parts of the device active no matter what, preventing it from going into Deep Sleep, the lowest CPU state.

I'll send you the log file asap.

Cheers

dylauthi

  • Newbie
  • *
  • Posts: 1
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #11 on: December 12, 2012, 12:17:50 pm »
I am also having the same problem.
« Last Edit: December 12, 2012, 12:23:55 pm by dylauthi »

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #12 on: December 15, 2012, 03:22:20 am »
Looks like over 14 hours, the app used 9 and a half minutes, is that considered excessive?
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

doctorow

  • Jr. Member
  • **
  • Posts: 87
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #13 on: December 15, 2012, 10:39:36 am »
Looks like over 14 hours, the app used 9 and a half minutes, is that considered excessive?

I think it says 14 minutes. ;)

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Aqua Mail doing well in terms of CPU consumption, but could do better
« Reply #14 on: December 19, 2012, 03:33:50 am »
Ah, right. Yes, this is not good.

dylauthi, is it still like this? If you're still using the app, that is :)
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/