- 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
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
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
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
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
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
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
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
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
It will help to figure out if calling Binder.getTransactionName has a
performance impact.
Test: manual
Change-Id: I0c9abd2ff3c5255bd67321645dfbf7eda54736bf
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
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
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
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
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
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