Commit Graph

519 Commits

Author SHA1 Message Date
Tej Singh
8b914c0f00 Remove alarm manager dependency from anomalyalarms
Anomaly alarms, which are used for prediction-base duration metric
anomaly detection, currently use alarm manager for setting alarms. This
can result in excessive binder calls to SCS to set/cancel the alarms if
the duration metric that the alarm is based on gets stopped/started in
quick succession.

To resolve this without losing precision, we can instead rely on the
flow of events into the statsd socket for this prediction. The socket
receives events very frequently, so there should be minimal (if any)
loss of precision, and we can remove the binder call entirely.

One concern is that we used to hold a wakelock when the alarm fired
(since alarm manager would hold a wakelock), and we now lose this
ability.

Test: atest statsd_test
Test: atest AnomalyDetectionTests
Bug: 161326200
Bug: 152642091
Change-Id: If37e5c6ccd8efa4e822c70a0444fa6b5a31bebca
Merged-In: If37e5c6ccd8efa4e822c70a0444fa6b5a31bebca
2020-10-09 16:05:57 -07:00
Kelly Rossmoyer
2837883e87 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

BUG=161896447

Test: make (change is only comments + 1 log message)

Change-Id: I8a21ef4ce19c517853388d8f7542f3a0cf8d91d5
Merged-In: I26ef8e079bf13f19bdc3bbc8219f572a43b68090
2020-09-10 13:55:33 -07:00
Xin Li
628590d7ec Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Tom Cherry
ed93b3f904 Delete more unused includes in statsd
Test: build
Merged-In: Ie639f57f86c2573cd5e06a1fa9397487f4b3f235
Change-Id: Ie639f57f86c2573cd5e06a1fa9397487f4b3f235
2020-07-28 21:12:29 +00:00
Treehugger Robot
246140a9a3 Merge "Fix edge case in statsd alarms" 2020-06-30 17:10:11 +00:00
Tej Singh
cb396eb711 Fix edge case in statsd alarms
Right now, if an alarm fires exactly on time (within 1 second), or
exactly on a multiple of its period, statsd will reset the alarm for the
same time, which can result a loop of statsd setting an alarm, the alarm
firing, statsd setting an alarm at the same time, etc.

The fix is that if an alarm fires on time, we should move to the next
period.

Test: atest statsd_test (added to a test, which would fail without the
code change)
Bug: 159098080

Change-Id: I150538cb1d3d5a2b943df2a32d92f8f84bb96626
Merged-In: I150538cb1d3d5a2b943df2a32d92f8f84bb96626
2020-06-30 04:46:38 +00:00
TreeHugger Robot
3b4893abee Merge "Fix edge case in statsd alarms" into rvc-dev am: ac2c18c314
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12004848

Change-Id: Ib178e5d7f50152478543de24b29854b411567898
2020-06-26 20:06:44 +00:00
Tej Singh
f5cd94b4d0 Fix edge case in statsd alarms
Right now, if an alarm fires exactly on time (within 1 second), or
exactly on a multiple of its period, statsd will reset the alarm for the
same time, which can result a loop of statsd setting an alarm, the alarm
firing, statsd setting an alarm at the same time, etc.

The fix is that if an alarm fires on time, we should move to the next
period.

Test: atest statsd_test (added to a test, which would fail without the
code change)
Bug: 159098080

Change-Id: I150538cb1d3d5a2b943df2a32d92f8f84bb96626
2020-06-25 22:38:03 -07:00
Jeffrey Huang
89ce5f1d6d Merge "Add pullTimeoutDurations to statsdstats" into rvc-dev am: caa0c3758d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11881634

Change-Id: I60366d85193647f52b707fc3d8b674f3a32ad41e
2020-06-18 19:12:46 +00:00
Jeffrey Huang
caa0c3758d Merge "Add pullTimeoutDurations to statsdstats" into rvc-dev 2020-06-18 19:11:46 +00:00
Jeffrey Huang
3b6aa146ef Add pullTimeoutDurations to statsdstats
Bug: 156790145
Test: atest statsd_test
Change-Id: Iaf6ceb94bb8729cb73e5e067b15f369dca1f52d8
2020-06-18 10:44:57 -07:00
Ruchir Rastogi
dbcef6a7f7 Merge "Fix TestSubscriberDimensionWrite" into rvc-dev am: eac39c521b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11887211

Change-Id: I562699cad312de1e0d9901c1105ad6648d8319a4
2020-06-17 16:04:23 +00:00
Ruchir Rastogi
eac39c521b Merge "Fix TestSubscriberDimensionWrite" into rvc-dev 2020-06-17 15:49:25 +00:00
Ruchir Rastogi
197107c007 Fix TestSubscriberDimensionWrite
Test: m statsd_test && adb sync data && adb shell
data/nativetest64/statsd_test/statsd_test64
Bug: 148954476
Change-Id: I3d2112f85460701d49103a5bfdc8cf0829ea091a

Change-Id: I07813393c6226252ee839ab16f411f9f92442ada
2020-06-16 17:06:23 -07:00
TreeHugger Robot
5cda9d0acd Merge "Mark bucket as condition_unknown properly" into rvc-dev am: 97d794084d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11855571

Change-Id: I54c7672d1cb6e436dcdcce84c66c40d61ed6c072
2020-06-15 21:35:02 +00:00
TreeHugger Robot
97d794084d Merge "Mark bucket as condition_unknown properly" into rvc-dev 2020-06-15 21:22:24 +00:00
Tej Singh
756541526a Mark bucket as condition_unknown properly
Previously, if the condition was unknown for the entire bucket, the
bucket would be annotated with a NO_DATA rather than being dropped
because CONDITION_UNKNOWN. This updates all the buckets to be dropped
due to CONDITION_UNKNOWN. Note that this will make the condition unknown
problem appear worse, when in reality it is making our bucket drop
reasons more correct and should not have any impact on the true
CONDITION_UNKNOWN.

Also fix an issue where a test was failing due to a previous test
leaving data persisted to disk. This fix is a hack for now, and should
be properly fixed later.

Bug: 158897179
Test: atest statsd_test
Change-Id: Ic703600d37aa1873ec67cb1a279dcf349d48fc9f
2020-06-13 03:50:59 -07:00
TreeHugger Robot
2b177cf853 Merge "Fix testMultipleConditions flake" into rvc-dev am: ecb9cfe093
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11856230

Change-Id: Id05a6ba2f99349b857a6d0bfd7066705281aa998
2020-06-13 02:44:29 +00:00
TreeHugger Robot
ecb9cfe093 Merge "Fix testMultipleConditions flake" into rvc-dev 2020-06-13 02:42:54 +00:00
Muhammad Qureshi
89358feae4 Fix testMultipleConditions flake
Use vector<int> instead of vector<bool>.
vector<bool> is not thread-safe:
https://en.cppreference.com/w/cpp/container#Thread_safety

Fixes: 156690351
Test: atest --iterations=500
statsd_test:MultiConditionTrigger#TestMultipleConditions

Change-Id: I9121747ffbee0864afbff993e7fe417104827952
2020-06-12 18:09:34 -07:00
Jeffrey Huang
9626e7ea99 Merge "Avoid timestamp update when data is kept on dump" into rvc-dev am: 0017b441a8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11829658

Change-Id: I2393fdc0e08e0b4c719d34765e900aab84b73d07
2020-06-11 18:42:43 +00:00
Jeffrey Huang
0017b441a8 Merge "Avoid timestamp update when data is kept on dump" into rvc-dev 2020-06-11 18:27:49 +00:00
Jeffrey Huang
289eae6dbd Avoid timestamp update when data is kept on dump
Bug: 158703584
Test: atest statsd_test
Change-Id: Ia6814c2cdb67dde2fd790ddc18fc785b1bba062c
2020-06-10 19:01:35 -07:00
Tej Singh
ca782b8885 Merge "Remove invalid configs from memory" into rvc-dev am: 0df64158ff
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11815608

Change-Id: I73f8793a12f604522ca68e1a3c4e763db200198a
2020-06-11 01:06:32 +00:00
Tej Singh
0df64158ff Merge "Remove invalid configs from memory" into rvc-dev 2020-06-11 01:04:21 +00:00
Tej Singh
5a4727d78b Remove invalid configs from memory
Right now if we receive an invalid config update, we keep the existing
config in memory. This makes us remove the existing config so that we
don't have any config for the invalid config key.

Test: atest statsd_test
Bug: 158617758
Change-Id: I9daecb1c96e3a63fea3a45b07d1295f3b4ba452a
2020-06-09 18:50:25 -07:00
Christine Tsai
8b32036372 Merge "Set current state key earlier and do not reset hasCurrentState" into rvc-dev am: 0e6be91fd2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11719486

Change-Id: I7b1c96fd932c57eb79e8c44a39dfb0f833aad0b8
2020-06-06 00:49:42 +00:00
tsaichristine
0893db53f5 Set current state key earlier and do not reset hasCurrentState
- The current state key was updated to the new state key after the diff
calculations and base setting. There are a few cases where we exit the
current loop which results in the current state key not getting updated.
- When we reset the base, we should not reset the current state. All
instances where hasCurrentState was set to false have been removed.
- I added a unit test for a value metric that is sliced by state and has
a condition.

Bug: 157661456
Test: m statsd_test && adb sync data && adb shell
data/nativetest/statsd_test/statsd_test32

Change-Id: Ib75bd9d08e6785f9e03b4b5984dbdaf86a7e1749
2020-06-05 15:26:20 -07:00
TreeHugger Robot
652de5f9fd Merge "Fix ConditionUnknown after valid buckets" into rvc-dev am: a78a19b336
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11740347

Change-Id: I80560010d313335d2d6ab69aefe615c210753e9d
2020-06-05 02:21:59 +00:00
Jeffrey Huang
3be5671c03 Fix ConditionUnknown after valid buckets
Because non-zero enums are evaluated to true, it is possible for pulls
to occur on bucket split even if the condition is unknown. Explicitly
check that the condition is true instead.

Bug: 155489707
Test: atest statsd_test
Change-Id: I0bc3de6e885c2200885caf01d07c793b83eca17a
2020-06-04 16:54:04 -07:00
Christine Tsai
d4fbf28628 Merge "Pass initial conditions to combination conditions and metrics" into rvc-dev am: c5111c995b
Original change: undetermined

Change-Id: Ic172143b38d760ab5bd3db277e02802d86515a65
2020-06-01 21:36:44 +00:00
tsaichristine
6e2e92d968 Pass initial conditions to combination conditions and metrics
SimplePredicates have a configurable initial value that can be set to
unknown or false. Previously, CombinationPredicates and MetricProducers
were automatically initialized with an unknown condition value instead
of being synced with the conditions of the SimplePredicates that they
rely on.

An initial condition cache is used to store initial conditions of
ConditionTrackers after they are initialized.
CombinationConditionTrackers evaluate their initial condition based on
the initial conditions of their child SimpleConditionTrackers.
MetricProducers also use the initial condition cache to set its
condition during initialization.

Added unit tests in SimpleConditionTracker_test to check that
SimpleConditionTrackers have the correct initial conditions based on
what the InitialValue is set to and the condition is updated properly
after the first few condition change events.

Added unit test in MetricsManager_test to check that all
ConditionTrackers and MetricProducers have the correct initial
conditions.

Test: m statsd_test && adb sync data && adb shell
data/nativetest64/statsd_test/statsd_test64
Bug: b/156762672

Change-Id: I9f6088f8c92fb18eb2ca8632aaa338fb0ed8e679
2020-06-01 09:25:02 -07:00
Howard Ro
999957ab38 Merge "Decrease default pull timeout to 2 seconds." into rvc-dev am: ceb2602851
Change-Id: I390613a08d411427b94504e5da347bb2fe0da2dc
2020-05-30 10:17:46 +00:00
Howard Ro
ceb2602851 Merge "Decrease default pull timeout to 2 seconds." into rvc-dev 2020-05-30 09:59:13 +00:00
TreeHugger Robot
7be1a3e8c0 Merge "Refactor ValueMetricProducer bucket flush" into rvc-dev am: eaf58a156b
Change-Id: Id3435479e7475f415b9dcb6ba90f6c5a19f13d2d
2020-05-30 09:16:38 +00:00
TreeHugger Robot
eaf58a156b Merge "Refactor ValueMetricProducer bucket flush" into rvc-dev 2020-05-30 09:01:49 +00:00
Howard Ro
124e9fb083 Merge "Populate initial base info with unknown state values" into rvc-dev am: c02b6d445a
Change-Id: I3b374dc6b0d4b041dd9f7d5fa773cd29e2b756ef
2020-05-30 07:55:08 +00:00
Howard Ro
c02b6d445a Merge "Populate initial base info with unknown state values" into rvc-dev 2020-05-30 07:41:25 +00:00
Jeffrey Huang
56ff8f3422 Refactor ValueMetricProducer bucket flush
refactor to simplify the condition nesting in flushCurrentBucketLocked

Bug: 157155330
Test: atest statsd_test
Change-Id: Ieff0e8d8d65e1a4c9fc576e68fd7fa912849f806
2020-05-29 17:15:19 -07:00
Tej Singh
73bad98e46 Decrease default pull timeout to 2 seconds.
This can result in more pull failures, but can prohibit slow pullers
from slowing down statsd.

Test: atest GtsStatsdHostTestCases
Test: atest statsd_test
Test: atest FrameworkStatsdTest
Bug: 154056912
Change-Id: Ie30bd3584d808bb11aaaf0fe2057c9adfb198644
2020-05-29 23:37:03 +00:00
TreeHugger Robot
590486af0d Merge "Restrict state event logging" into rvc-dev am: 938216c073
Change-Id: I9776fc24d6843ec8a078b9d1cce1d53fe310a183
2020-05-29 08:03:57 +00:00
TreeHugger Robot
938216c073 Merge "Restrict state event logging" into rvc-dev 2020-05-29 07:50:58 +00:00
tsaichristine
5088e72c53 Populate initial base info with unknown state values
Set the current state key to a HashableDimensionKey with -1
(kStateUnknown) for each sliced state atom. Previously, the current
state key was being set to the DEFAULT_DIMENSION_KEY which is an empty
HashableDimensionKey.

Bug: 155487198
Test: make statsd_test && adb sync data && adb shell
data/nativetest/statsd_test/statsd_test

Change-Id: Icaa187ecae599407695d86eec6104d210aa98714
2020-05-28 10:50:08 -07:00
Muhammad Qureshi
7ce2256a72 Restrict state event logging
Restrict state event logging to AID_* and Mainline module uids.

Bug: 145706772
Test: statsd_test
Change-Id: I5dc244bd1c6c55dc0213c6e236aea93d759b675f
2020-05-27 16:18:12 -07:00
Jeffrey Huang
ef4eaa6f42 Merge changes Id23aea5b,I9b5655a2,I17bb6b9f into rvc-dev am: 8eaf1aba00
Change-Id: Id459258f3b6a2048122f54ace2c1b4fd5841a60c
2020-05-26 22:08:32 +00:00
Jeffrey Huang
f108912d25 Avoid coverage gaps from forced bucket splits
Bug: 157155330
Test: atest statsd_test
Change-Id: Id23aea5b45dc5c3c5cf46b36d9cb2451ee4cf516
2020-05-26 12:35:04 -07:00
Jeffrey Huang
de3348ae33 Update ValueMetric to use NO_DATA
Bug: 157155330
Test: atest statsd_test
Change-Id: I9b5655a2a7e81cca150ffe91662ef51e64f66cdf
2020-05-26 12:20:53 -07:00
Christine Tsai
cadd28408d Merge "Change SimplePredicate InitialValue default to UNKNOWN" into rvc-dev am: d7b08c7690
Change-Id: I1e8d40d1ba56bf6225e1aa708af367986c479cec
2020-05-19 20:45:02 +00:00
Christine Tsai
d7b08c7690 Merge "Change SimplePredicate InitialValue default to UNKNOWN" into rvc-dev 2020-05-19 20:30:00 +00:00
tsaichristine
70a7ee5f60 Change SimplePredicate InitialValue default to UNKNOWN
Previous default for InitialValue was FALSE. Currently, no predicates
configure this field.

Added unit tests to test the initial condition changes in Value and
Count metrics.
- ValueMetricE2eTest.TestInitialConditionChanges
- CountMetricE2eTest.TestInitialConditionChanges

Bug: b/156541904
Test: m statsd_test && adb sync data && adb shell data/nativetest/statsd_test/statsd_test
Change-Id: I242bcb0b60455355e699636aae7e620fabc310ef
2020-05-19 10:39:46 -07:00