Commit Graph

9954 Commits

Author SHA1 Message Date
TreeHugger Robot
17e78cef39 Merge "Improve binder calls stats sampling." 2018-08-06 22:53:16 +00:00
TreeHugger Robot
35863cda9a Merge "Minor changes on top of memory leak fix ag/4607657" 2018-08-06 22:51:36 +00:00
Hui Yu
10571e0ce5 Minor changes on top of memory leak fix ag/4607657
Fix: 80443940
Test: "adb shell cmd battery unplug" and "adb shell cmd battery set ac 1",
observe memory usage from Android Monitor.

Change-Id: If095a5a88bf43485f2b1ab6da4cab0c87099b90b
2018-08-06 13:20:55 -07:00
Olivier Gaillard
359e2eef15 Merge "Set default sampling period to 100." 2018-08-06 20:11:42 +00:00
Olivier Gaillard
0d5f50428b Merge "Remove unused imports" 2018-08-06 20:10:48 +00:00
arangelov
8eedb5ad40 Merge "No disclaimer when switching profile for system SMS and dialer apps." into pi-dev am: a7a496f3a1
am: 487ca863a0

Change-Id: I7d5a8a2e2784adc31ae0f366cf81650819228007
2018-08-06 11:00:57 -07:00
arangelov
487ca863a0 Merge "No disclaimer when switching profile for system SMS and dialer apps." into pi-dev
am: a7a496f3a1

Change-Id: I7a14ee395b21c8b6d9c81dc6d13497110bc336b4
2018-08-06 10:44:32 -07:00
Olivier Gaillard
34ad8af018 Improve binder calls stats sampling.
- Decouple detailed tracking and sampling. Detailed tracking now control
which data wwe should track (e.g. exception, max reply size, ...),
sampling controls the % of requests to track
- Do not create a CallStat object just for the sake of tracking the call
count. Most of the keys have a really low call count (60% of keys below
10 call counts, 90% below 100 calls). When data sampling is enabled, we
can save lots of memory.

Test: unit test
Change-Id: If81b38023a76a8b1e07e655f9ecd8a098d401df4
2018-08-06 16:49:26 +01:00
Olivier Gaillard
c0eadf9976 Set default sampling period to 100.
Test: unit test
Change-Id: I23fb6dbb6de75c948c30b71bb93eaab557090424
2018-08-06 16:49:26 +01:00
Olivier Gaillard
94e6fe61c7 Remove unused imports
Test: unit test
Change-Id: I01c4d0001fa76cb79f1c40ce40d9a55e3bd5623a
2018-08-06 16:49:25 +01:00
Hui Yu
8e88e955a6 Fix memory leak in TimeBase.mObservers list.
Leaks happen in following places:
1. Not all timer/counter in Uid class are detached from TimeBase when
the Uid object is destructed.
2. When Uid object is removed from mUidStats list in
onUserRemovedLocked, removeUidStatsLocked, readLocked, All
timer/counter in Uid class are not detached from TimeBase.
3. When timer/counter in Uid class is reassigned, the previous
timer/counter object is not detached.

Performance improvement:
The mObservers list in TimeBase object of BatteryStatsImpl can have
size up like 20k, the list type is ArrayList, remove() method on
ArrayList is very slow. For long mObservers list, we change to use
HashSet as container. The mObservers list in TimeBase object of Uid
is short, it continues to use ArrayList as container.

Fix: 80443940
Test: "adb shell cmd battery unplug" and "adb shell cmd battery set ac 1",
observe memory usage from Android Monitor.

Change-Id: I2001ca390a0a86a32082e1012dde4b831f1e7d04
2018-08-03 19:08:37 -07:00
arangelov
64439c1e8c No disclaimer when switching profile for system SMS and dialer apps.
This CL prevents the Toast message from showing when the following
conditions are met:
1. App is system app
2. Intent action is either ACTION_DIAL or ACTION_CALL or if it is
ACTION_SENDTO, only skip if data scheme is one of "sms:", "smsto:",
"mms:" or "mmsto:".

Bug: 111228250
Test: atest FrameworksCoreTests:IntentForwarderActivityTest
Change-Id: Idef71ff2928e9e3d72bad4ba8ff17f9306e91d25
2018-08-02 14:52:30 +01:00
Olivier Gaillard
af17609d6e Merge "Add support for battery/screen state changes." 2018-08-02 08:33:17 +00:00
TreeHugger Robot
bd1056fc2a Merge changes from topic "biometric-prompt"
* changes:
  Refactor FingerprintDialog to be Biometric
  Clean up interface between controller and view
2018-08-02 05:42:34 +00:00
Olivier Gaillard
86714d1347 Add support for battery/screen state changes.
Only collect data when the device is charging to be consistent with what
battery stats is doing.

Add a screen interactive dimension to have more context to analysis the
binder calls data.

Test: unit test
Change-Id: Id31c53ae315d905e5d8e67918f64780f34ff5d72
2018-08-01 21:03:59 +01:00
Kweku Adams
ef0c08fe7e Fixing proto field name style.
Bug: 110957691
Test: Android builds
Change-Id: I9a7dbe3a6522b243cfd1df85eeae22395ff000ae
2018-08-01 11:55:07 -07:00
TreeHugger Robot
60538cce45 Merge "Add tracking of process run time." 2018-08-01 18:38:51 +00:00
Olivier Gaillard
b812229775 Binder calls stats cleanup
Test: unit test
Change-Id: I6e621de1be211cf1e4fbf61aea8447dac83aee8e
2018-08-01 13:57:30 +01:00
Olivier Gaillard
f31dfb94f8 Optimize resolving transaction codes.
Do the heavy work outside of the main lock and only resolve the same
method once.

Test: unit test
Change-Id: I083b3e66d35178311b5ee71443b39efe1112ad55
2018-07-31 22:49:29 +01:00
Dianne Hackborn
99aeba896e Add tracking of process run time.
To help identify processes RAM growth over time, we keep
keep track of the total time the current process has been
running and its RAM use during that time.  Then we can look
at how large processes are based on how long they have been
running for.

See "Cur time" here:

  * com.google.android.inputmethod.latin / u0a124 / v26731214:
      Process com.google.android.inputmethod.latin:train (unique, 6 entries):
        SOff/Norm/(Cch Emty): +1m4s338ms
              Mod/(Cch Emty): +15s977ms
              Low/    Imp Bg: +6s272ms
                     Service: +239ms
                  (Cch Emty): +2s874ms
             Crit/    Imp Bg: +1s52ms
                       TOTAL: +1m30s752ms
        PSS/USS (1 entries):
          SOff/Norm/(Cch Emty): 11MB-11MB-11MB/5.6MB-5.7MB-5.7MB/5.6MB-34MB-62MB over 2
        Cur time +30s214ms: 11MB-11MB-11MB/5.7MB-5.7MB-5.7MB/62MB-62MB-62MB over 1
      Process com.google.android.inputmethod.latin (unique, 6 entries):
        SOff/Norm/    Imp Bg: +2h22m18s830ms
              Mod/    Imp Bg: +15s977ms
              Low/    Imp Bg: +12s98ms
             Crit/    Imp Bg: +32s815ms
         SOn/Norm/    Imp Bg: +53m13s63ms
             Crit/    Imp Bg: +4s170ms
                       TOTAL: +3h16m36s953ms
        PSS/USS (3 entries):
          SOff/Norm/    Imp Bg: 27MB-31MB-34MB/21MB-27MB-30MB/21MB-33MB-88MB over 11
                Mod/    Imp Bg: 25MB-29MB-32MB/19MB-23MB-26MB/19MB-56MB-92MB over 2
           SOn/Norm/    Imp Bg: 34MB-34MB-34MB/30MB-31MB-31MB/30MB-61MB-91MB over 2
        Cur time +2m47s741ms: 27MB-28MB-28MB/21MB-21MB-21MB/21MB-54MB-88MB over 2

Bug: 110957691
Test: manual
Change-Id: I33b291555fd125b3791752cb10de48300bb21706
2018-07-31 14:45:11 -07:00
Olivier Gaillard
1f93a77b5c Resolves transaction codes lazily when a dump is requested.
This change allows to save:
- some memory by removing the method name from CallStat and CallSession
- some CPU by not calling binder.resolveCode for every binder call
at the expense of some hackiness (calling getDefaultTransactionCode
using reflection)

BinderCallsStats#getExportedCallsStats is now more costly to call but it
will be invoked only once a day only.

Test: unit test
Change-Id: Id4f933644c6da9d4aa2d0671db4ab80676eac1b0
2018-07-31 15:18:12 +00:00
Sudheer Shanka
b19b3f1a68 Merge "Pass the packageName to zygote when starting a new process." 2018-07-31 01:02:17 +00:00
Sudheer Shanka
154fe3f6a7 Pass the packageName to zygote when starting a new process.
This packageName is passed so that the process initialization
after the zygote fork can mount appropriate package sandbox.

Bug: 111890351
Test: n/a
Change-Id: I99d6c1b53fffd53d7387dc807106efe5e1dc9b07
2018-07-30 14:44:26 -07:00
Olivier Gaillard
7a2a98bb7f Store the runtime class instead of the class name.
This will be used by a follow up CL to call getTransactionCode lazily
instead of doing it during the binder call.

Test: unit tests
Change-Id: I11a997bb8a6268871daf4145a962886b43195c89
2018-07-30 17:59:30 +00:00
Olivier Gaillard
5536929078 Merge "Move a few method calls outside the BinderCallsStats lock." 2018-07-30 17:59:07 +00:00
Olivier Gaillard
8a760b9143 Move a few method calls outside the BinderCallsStats lock.
getThreadTimeMicro can take a few microseconds.

Change-Id: I3dc451ded2bde147c1b9061552210d499ec7d0e3
Test: unit tests
2018-07-30 11:19:49 +01:00
Jeff Sharkey
3ea5588f7c Merge "Support for appending "standalone" WHERE chunks." 2018-07-27 23:21:53 +00:00
TreeHugger Robot
ac70654f9d Merge "Procstats: keep track of per-proc state active time" 2018-07-27 21:26:41 +00:00
Jeff Sharkey
b89df9eac8 Support for appending "standalone" WHERE chunks.
The existing appendWhere() methods aren't very friendly for
developers, since they require manual tracking of state to decide if
subsequent standalone chunks should be prefixed with "AND".

While it's tempting to offer direct argument binding on the builder
class, we can't really deliver on that API in a secure way, so instead
add separate bindSelection() method which explicitly burns arguments
into a standalone selection string, which can then be appended to
the builder.

This was the last piece of new functionality being used by
SQLiteStatementBuilder, so we can delete that class and migrate
users back to SQLiteQueryBuilder.

Bug: 111268862
Test: atest frameworks/base/core/tests/coretests/src/android/database/DatabaseUtilsTest.java
Test: atest frameworks/base/core/tests/utiltests/src/com/android/internal/util/ArrayUtilsTest.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Test: atest cts/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
Change-Id: I418f24338c90bae8a9dad473fa76329cea00a8c5
2018-07-27 13:45:51 -06:00
Sudheer Shanka
352a72ca09 Merge "Don't track per process state cpu times by default." 2018-07-27 17:21:41 +00:00
Olivier Gaillard
dd9e03a151 Merge "Disable collecting binder call stats by default." 2018-07-26 12:37:58 +00:00
Olivier Gaillard
a14d5b289c Disable collecting binder call stats by default.
It will help to figure out if calling Binder.getTransactionName has a
performance impact.

Test: manual
Change-Id: I0c9abd2ff3c5255bd67321645dfbf7eda54736bf
2018-07-26 11:51:38 +01:00
Olivier Gaillard
6f52d1572d Pull more data from binder calls.
Exceptions counts by class name and few new fields for binder calls.

> adb shell cmd stats pull-source 10023
Pull from 10023: { 1532528725000000000 49754068496 (10023)0x10000->java.lang.SecurityException[S] 0x20000->2[I]  }
Pull from 10023: { 1532528725000000000 49754068496 (10023)0x10000->java.lang.IllegalArgumentException[S] 0x20000->16[I]  }

Test: manual
Change-Id: I4d24528a7df8edde87f629837fb3117a0504d09e
2018-07-25 23:43:19 +01:00
Olivier Gaillard
289ba40237 Adds an Observer interface to observes binder API calls.
This is the first step to move BinderCallsStats implementation to the
server package in order to have an implementation more specific to the
system server (tracking charger on/off).

Removes the volatile keywords in BinderCallsStats.

Also exposes a clean API to StatsCompanionService instead of
BinderCallsStats directly.

Test: unit test
Change-Id: Ied98c555acc8489420104098561b4608346509b5
2018-07-25 21:20:59 +00:00
Dianne Hackborn
7aea7a4c22 Procstats: keep track of per-proc state active time
Associations now keep track of how long the association
was active for each process state that is seen in that
association.  This allows to better correlate how associations
are keeping the overall process in RAM.

Also do some cleanup of the dump output in various places
to make it more consistent.

For example, here is what we can now see about the contacts
provider:

Per-Package Stats:
  * com.android.providers.contacts / u0a13 / v28:
      Process android.process.acore (multi, 16 entries):
        SOff/Norm/    Imp Fg: +6s770ms
                      Imp Bg: +2s970ms
                     Service: +58ms
                    Receiver: +241ms
                  (Last Act): +2m55s844ms
                  (Cch Emty): +19m34s250ms
              Mod/(Last Act): +3s248ms
              Low/(Last Act): +4s585ms
             Crit/    Imp Fg: +1s273ms
                  (Last Act): +114ms
         SOn/Norm/       Top: +8m5s440ms
                      Imp Fg: +5s399ms
                      Imp Bg: +7s890ms
                     Service: +347ms
                  (Last Act): +12m28s564ms
                  (Cch Emty): +45s874ms
                  TOTAL  : +44m22s867ms
        PSS/USS (4 entries):
          SOff/Norm/(Last Act): 1 samples 10MB 10MB 10MB / 8.9MB 8.9MB 8.9MB / 60MB 60MB 60MB
                    (Cch Emty): 3 samples 8.2MB 9.2MB 11MB / 6.7MB 7.6MB 9.3MB / 6.7MB 24MB 57MB
           SOn/Norm/       Top: 4 samples 11MB 11MB 11MB / 9.8MB 9.8MB 9.8MB / 9.8MB 23MB 62MB
                    (Last Act): 3 samples 12MB 13MB 13MB / 11MB 11MB 11MB / 11MB 29MB 64MB
        myID=d0cbaa1 mCommonProcess=8ceb4c6 mPackage=com.android.providers.contacts
        Common Proc: android.process.acore/10013 pkg=com.android.providers.contacts
      Association com.android.providers.contacts.CallLogProvider:
        Process: android.process.acore
        mNumActive=0
          <- system / 1000:
             Total count 1: Duration +16ms / 0.00%
             Active count 1 (inline):
                Imp Fg: Duration +16ms / 0.00%
                 TOTAL: Duration +16ms / 0.00%
          <- com.google.android.dialer / u0a40:
             Total count 4: Duration +428ms / 0.02%
             Active count 1 (inline):
              Receiver: Duration +428ms / 0.02%
                 TOTAL: Duration +428ms / 0.02%
          <- com.google.android.as:nonpersistent / u0a48:
             Total count 8: Duration +287ms / 0.01%
          <- com.android.calllogbackup / u0a13:
             Total count 1: Duration +29ms / 0.00%
             Active count 1 (inline):
                Imp Bg: Duration +29ms / 0.00%
                 TOTAL: Duration +29ms / 0.00%
      Association com.android.providers.contacts.VoicemailContentProvider:
        Process: android.process.acore
        mNumActive=0
          <- com.google.android.dialer / u0a40:
             Total count 2: Duration +325ms / 0.01%
      Association com.android.providers.contacts.ContactsProvider2:
        Process: android.process.acore
        mNumActive=0
          <- com.google.android.apps.messaging / u0a129:
             Total count 5: Duration +12m49s649ms / 27%
             Active count 1 (inline):
                Imp Bg: Duration +12m49s649ms / 27%
                 TOTAL: Duration +12m49s649ms / 27%
          <- system / 1000:
             Total count 156: Duration +3s35ms / 0.11%
             Active count 2 (inline):
                Imp Fg: Duration +3s35ms / 0.11%
                 TOTAL: Duration +3s35ms / 0.11%
          <- com.google.android.googlequicksearchbox:search / u0a62:
             Total count 2: Duration +582ms / 0.02%
             Active count 2 (inline):
                Imp Bg: Duration +582ms / 0.02%
                 TOTAL: Duration +582ms / 0.02%
          <- com.google.android.gm / u0a83:
             Total count 3: Duration +97ms / 0.00%
          <- com.google.android.dialer / u0a40:
             Total count 3: Duration +21m31s285ms / 46%
          <- com.google.android.as:nonpersistent / u0a48:
             Total count 8: Duration +658ms / 0.02%
          <- com.google.android.contacts / u0a117:
             Total count 5: Duration +2s785ms / 0.10%
             Active count 3 (multi-field):
                Imp Bg: Duration +371ms / 0.01%
              Receiver: Duration +72ms / 0.00%
                 TOTAL: Duration +443ms / 0.02%
          <- com.google.android.gms / u0a36:
             Total count 208: Duration +8s924ms / 0.31%
             Active count 50 (multi-field):
                Imp Fg: Duration +3s329ms / 0.12%
                Imp Bg: Duration +67ms / 0.00%
               Service: Duration +10ms / 0.00%
                 TOTAL: Duration +3s406ms / 0.12%
          <- com.android.ims.rcsservice / 1001:
             Total count 4: Duration +387ms / 0.01%
             Active count 1 (inline):
                Imp Fg: Duration +387ms / 0.01%
                 TOTAL: Duration +387ms / 0.01%
          <- com.android.bluetooth / 1002:
             Total count 5: Duration +714ms / 0.03%
             Active count 4 (inline):
                Imp Fg: Duration +714ms / 0.03%
                 TOTAL: Duration +714ms / 0.03%
          <- com.google.process.gapps / u0a75:
             Total count 4: Duration +3m9s609ms / 6.7%
             Active count 16 (inline):
                Imp Bg: Duration +3m9s609ms / 6.7%
                 TOTAL: Duration +3m9s609ms / 6.7%

Bug: 110957691
Test: manual
Change-Id: I71bc15dbcc19da81157778e0ce1a91a848b59a04
2018-07-25 10:06:55 -07:00
Kevin Chyn
e927566c5a Refactor FingerprintDialog to be Biometric
Bug: 111704270

Test: tested with sample app, fingerprint UI still works fine
Change-Id: I6842f6589f6e9eaeee0482602605a0b149d3fc21
2018-07-24 13:01:40 -07:00
Neil Fuller
f24692dd0c Merge "Break some dependencies on libcore internals" am: f672c2bcb8 am: 8d59399398 am: e3b9960277
am: f221bd013f

Change-Id: I4d64c0a3c3f3c10482f395b32c5f348383114b4f
2018-07-24 03:09:44 -07:00
Neil Fuller
f221bd013f Merge "Break some dependencies on libcore internals" am: f672c2bcb8 am: 8d59399398
am: e3b9960277

Change-Id: Ie28a471c402b9e6405a44ef8c9b5855158d12b80
2018-07-24 02:56:51 -07:00
Neil Fuller
e3b9960277 Merge "Break some dependencies on libcore internals" am: f672c2bcb8
am: 8d59399398

Change-Id: I06ccaff955d476cd6490729703b0000cbd4aa496
2018-07-24 02:47:25 -07:00
Neil Fuller
8d59399398 Merge "Break some dependencies on libcore internals"
am: f672c2bcb8

Change-Id: I234d938606b07a5116c39dfcc378d55bcd521c2d
2018-07-24 02:33:02 -07:00
Olivier Gaillard
2c13c6f37b Binder calls stats - random sampling.
Change the sampling method to be random. The previous mechanism recorded
one call for each key (uid/API name) and every X calls for each key:
- This is biased and will make it to interpret the data from
westworld.  It was especially unfair for apps using many different APIs
since the first call to each API was always recorded.
- It uses more memory since we will keep track of all the long tail

Simplify/unify the way we keep track of sampled calls.

Do not estimate the CPU usage of non-recorded calls
    long samplesCount = cs.callCount / mPeriodicSamplingInterval + 1;
    duration = cs.cpuTimeMicros / samplesCount;
It biases the results, let's use an example with 3 calls: 1ms, 3ms, 5ms
with an sampling interval of 2. With the previous algorithm we would get an
average per call of (1+1+3+2+5)/5=2.4ms. With the new one (1+3+5)/3=3ms.

Test: unit tests
Change-Id: I1dd7eb3c6c631b86a53485bccbfa397882cccc92
2018-07-23 17:39:22 +01:00
Neil Fuller
a84056a3d0 Break some dependencies on libcore internals
This commit swaps some internal details of libcore for some
abstractions on dedicated "internal facing" APIs. This reduces the
number of internal APIs used. There is an associated change in
libcore/

Bug: 111055375
Test: build / boot
Change-Id: Idddada1922701bd15475c840eaa76c505e545d33
2018-07-23 16:02:00 +01:00
Mike Ma
a31b0cf871 Merge "Fix a NPE in BatteryStatsImpl" into pi-dev
am: 0587bdd59f

Change-Id: I3bcc5d38995a38f068df6251826050fd59325e80
2018-07-20 21:14:10 -07:00
TreeHugger Robot
0587bdd59f Merge "Fix a NPE in BatteryStatsImpl" into pi-dev 2018-07-21 00:59:59 +00:00
Hui Yu
6fc752c737 Revert "Fix the memory leak in BatteryStatsImpl.Timebase.mObservers."
This reverts commit 420ed9ef22.

Reason for revert: The WeakReference change can prevent memory leak, but 
but the extra time spend on creating thousands of WeakReference objects has slowed down system_server startup as reported by b/111658334. Revert this CL for now, will find other approach to prevent memory leak. 

Change-Id: I07a5806e36159467459b841f63e2b0c55b6cc10b
2018-07-20 19:51:17 +00:00
TreeHugger Robot
49b58654c5 Merge "Revert "Use ArraySet for the list of observer WeakReference."" 2018-07-20 19:21:58 +00:00
Hui Yu
8eeac7d338 Revert "Use ArraySet for the list of observer WeakReference."
This reverts commit 3488f1afcb.

Reason for revert: The change to ArraySet increase system_server startup time by 20ms as reported in b/111658334. It is because add() operation into ArraySet takes much longer than ArrayList. 

Change-Id: I1523332a8c9fc74cfef29b119a3c4c54d55596ec
2018-07-20 17:24:36 +00:00
TreeHugger Robot
680d6df80e Merge "Merge pi-dev-plus-aosp-without-vendor into stage-dr1-aosp-master" into stage-dr1-aosp-master 2018-07-20 06:03:51 +00:00
Jinguang Dong
741d2fa757 Merge "Ensure dropbox could copy tombstone files to special folder." am: 12cdea59d3 am: 3034085dff am: 38c07c31dd
am: 7e49326439

Change-Id: I22b4da6b09985d99de20f6fe4602441d49c40993
2018-07-19 16:50:56 -07:00
Jinguang Dong
7e49326439 Merge "Ensure dropbox could copy tombstone files to special folder." am: 12cdea59d3 am: 3034085dff
am: 38c07c31dd

Change-Id: Id462f492b9a7882c700d090dcfe5eb366f44556f
2018-07-19 16:12:12 -07:00