Skip to content

Commit

Permalink
performance: add Android battery/cpu profiling results (#210)
Browse files Browse the repository at this point in the history
Android docs for the battery/cpu analysis

Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
Alan Chiu authored and jpsim committed Nov 28, 2022
1 parent 7856770 commit adcd245
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
31 changes: 27 additions & 4 deletions mobile/docs/root/development/performance/battery_impact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,29 @@ iOS
Android
-------

We're currently using HttpURLConnection to communicate and send requests to Envoy. Envoy in it's current state is run as
a process

Getting the build:

1. Build the library using ``bazel build android_dist --config=android``
2. Control: ``bazel mobile-install //examples/kotlin/control:hello_control_kt``
3. Envoy: ``bazel mobile-install //examples/kotlin/hello_world:hello_envoy_kt --fat_apk_cpu=armeabi-v7a``

Experiment steps:

1. Set a phone's display to sleep after 30minutes of inactivity
2. Unplug the phone from any power source
3. Open up the demo app
4. Wait for the phone to sleep
5. Look at the battery drain from an application like `AccuBattery <https://play.google.com/store/apps/details?id=com.digibites.accubattery&hl=en_US>`_
5. Look at the battery drain the battery settings in the phone to see the battery usage and drainage

* TODO: Instructions on how to use AccuBattery
Alternative profiling methods tried:

1. `AccuBattery <https://play.google.com/store/apps/details?id=com.digibites.accubattery&hl=en_US>`_
We were unable to get the running time of a given application on AccuBattery to more accurately identify battery usage per minute
2. `Battery Historian <https://github.com/google/battery-historian>`_
We were unable to get reliable data using this method. Often times, the battery usage of an application appears to use no batteries

Results
~~~~~~~
Expand All @@ -45,7 +55,12 @@ iOS
Android
-------

* TODO
Through running the applications for 30minutes, the results are:

- Envoy : 0.17%/min
- Control : 0.18%/min

The results of Envoy and Control are very similar

Analysis
~~~~~~~~
Expand All @@ -58,7 +73,15 @@ iOS
Android
-------

* TODO
The results of this experiment is that there isn't much of a difference between Envoy and Control every 200ms. With the :repo:`CPU analysis </docs/root/development/performance/cpu_impact.rst>`,
we are able to see:

1. Requests to s3 are being logged in Envoy
2. DNS resolution does happen every 5 seconds
3. Stats are flushed every 5 seconds

The DNS resolution and stats flush happening every 5 seconds was a concern but updating the frequency to 1 minute, we
did not notice a big change.

Open issues regarding battery usage
-----------------------------------
Expand Down
27 changes: 24 additions & 3 deletions mobile/docs/root/development/performance/cpu_impact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ iOS
Android
-------

We're currently using HttpURLConnection to communicate and send requests to Envoy every 200ms.
Envoy in it's current state is run as
a process

Getting the build:

1. Build the library using ``bazel build android_dist --config=android``
2. Control: ``bazel mobile-install //examples/kotlin/control:hello_control_kt``
3. Envoy: ``bazel mobile-install //examples/kotlin/hello_world:hello_envoy_kt --fat_apk_cpu=armeabi-v7a``

Experiment steps:
* TODO

1. Run ``adb shell top -H | grep envoy`` to get the CPU usage of the application (the ``-H`` flag displays the running threads)
2. Wait 10minutes to gather a sample set of data to analyze
3. Take the average CPU% and MEM%

Results
~~~~~~~
Expand All @@ -37,7 +45,15 @@ iOS
Android
-------

* TODO
Envoy:

- Avg CPU: 33.16075949%
- Avg MEM: 2.765822785%

Control:

- Avg CPU: 28.81012658%
- Avg MEM: 2.169620253%

Analysis
~~~~~~~~
Expand All @@ -50,7 +66,12 @@ iOS
Android
-------

* TODO
The results of this experiment is that there is minimal difference between Envoy and Control. By enabling trace logging
within Envoy, we are able to observe the following:

1. Requests to s3 are being logged in Envoy
2. DNS resolution does happen every 5 seconds
3. Stats are flushed every 5 seconds

Open issues regarding battery usage
-----------------------------------
Expand Down

0 comments on commit adcd245

Please sign in to comment.