History log of /frameworks/base/cmds/statsd/src/logd/LogEvent.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9c1debe330006b2b4d5c08a55905789c57369609 19-Feb-2018 Yao Chen <yaochen@google.com> Add annotation to atoms that represent a state change in atoms.proto

+ A state change atom can have one exclusive state field, and any
number of primary key fields.

When there is primary key in the atom, it means the state belongs to the primary key.
For example,
message UidProcessStateChanged {
optional int32 uid = 1 [(stateFieldOption).option = PRIMARY];
optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE];
}

When there is no primary key fields in the atom, the state is global.
For example,
message ScreenStateChanged {
optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE];
}

+ The annotation is consumed by stats_log_api_gen to generate a static map from the state
atoms to its primary fields, and exclusive fields

+ stats_log.proto is splitted into 2 proto files, because statsd needs proto lite, and c++
lite proto library cannot properly ignore the field options which requires full proto.

This CL doesn't change any logic in the statsd yet. A separate CL will use the field option
information to correctly track the state.

Test: added unit tests in stats_log_api_gen_test. and statsd_test pases.
Change-Id: I9e8a979fe81ba60efd4d854bb7087ce4b2b147ec
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
330af58f2b8582b855085655fae553cdfaf44e6c 09-Feb-2018 Yangster-mac <yanglu@google.com> Use elapsed realtime instead of times based on wall clock, which can jump around and go backwards.

Test: statsd unit test passed

Change-Id: Ib541df99231e171b3be2a24f75632693e36da90e
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
8a8d16ceea1e5b7a2f8c41e17b5d993035f50f5d 08-Feb-2018 Yao Chen <yaochen@google.com> Statsd CPU optimization.

The key change is to revamp how we parse/store/match a log event, especially how we match repeated
field and attribution nodes, and how we construct dimensions and compare them.

+ We use a integer to encode the field of a log element. And also encode the FieldMatcher into an
integer and a bit mask. The log matching becomes 2 integer operations.

+ Dimension is stored as encoded field and value pair. Checking if 2 dimensions are equal is then
becoming checking if the underlying integers are equal. The integers are stored contiguously
in memory, so it's much faster than previous tree structure.

Start review from FieldValue.h

Test: statsd_test + new unit tests

Bug: 72659059

Change-Id: Iec8daeacdd3f39ab297c10ab9cd7b710a9c42e86
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
80f9112aecf08845ef0b2b132d721b7ce850970f 01-Feb-2018 Chenjie Yu <cjyu@google.com> Pullers merge isolated process with host

Test: unit test
Change-Id: Idcb4d19e1f5182554b503c5a35fbde4da146835c
Fix: 72230210
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
7ba8fc357e44ee3bb8e614c202852a1c46a9d4a8 25-Jan-2018 Yangster-mac <yanglu@google.com> Cpu usage optimization:
1/ Avoid unnecessary field/dimension proto construction.
2/ use unordered_map for slicing.
3/ Use dimension fields to compare dimension keys.

Test: all statsd tests passed.
Change-Id: I2f74f78589b7f6ecd0803a2ead822b8d0399f334
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
b5f12bbd2f30f93803dbb266c45d30cc44df3d36 25-Jan-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add statsd microbenchmark and fix a crash in LogEvent"
48d75189ccbfc06f24f315ff5b8a1a42cf8207c5 23-Jan-2018 Yao Chen <yaochen@google.com> Add statsd microbenchmark and fix a crash in LogEvent

+ We should benchmark the core functions in the critical path.
1. LogEvent parsing
2. Log matching
3. Event processing in various metrics
....

+ Using microbenchmark, we can quantify the optimization we do in the future.

---------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------
BM_LogEventCreation 4772 ns 4705 ns 145738

Test: make -j64 statsd_benchmark

Bug: 72242322

Change-Id: I43aa704ffdc7cd21e02ef9038eff66ca7022dbfb
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
68985805f26f5da6cc6b63934cb00fbff2741ca9 21-Jan-2018 Yangster-mac <yanglu@google.com> Avoid processing log event when there is no uid field.

Test: all statsd unit test passed

Change-Id: Id434d86586950a485b30a244f3c030e8202c1c6d
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
d40053eb8bcb19c7c3b080a36714566bb4e4a748 10-Jan-2018 Yangster-mac <yanglu@google.com> Map isolated uid to host uid when processing log event in statsD.

Test: added test case for isolated uid in Attribution e2e test.
Change-Id: I63d16ebee3e611b1ef0c910e5154cf27766cb330
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
2087716f2bdca90c7c3034d556ac12911bd8018e 23-Dec-2017 Yangster-mac <yanglu@google.com> 1/ Support nested message and repeated fields in statsd.
2/ Filter gauge fields by FieldMatcher.
3/ Wire up wakelock attribution chain.
4/ e2e test: wakelock duration metric with aggregated predicate dimensions.
5/ e2e test: count metric with multiple metric condition links for 2 predicates and 1 non-sliced predicate.

Test: statsd unit test passed.

Change-Id: I89db31cb068184a54e0a892fad710966d3127bc9
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
d10f7b1c7bdb1c66aa04148945cae9733ee4cadf 18-Dec-2017 Yao Chen <yaochen@google.com> Add log source filtering in statsd to filter out spams.

+ Add log source whitelist in StatsdConfig
+ Some changes in UidMap API. Listener needs to be wp instead of sp.
+ Update dogfood app config to have log source
+ Increase the stats service thread pool size to 10 (9+1).

TODO: add unit tests(b/70805664). This unit test takes some time to write.

Test: statsd_test & manual

Change-Id: I129b1cc13db5114db7417580962bd7cc4438519d
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
d9dfda76e0aa8b8aa4d2562a7ff4259f4500e355 12-Dec-2017 Chenjie Yu <cjyu@google.com> add feature: GaugeMetricProducer now takes repeated list of fields
bug fix: GaugeMetricProducer now works better with pulled events.
unit test also includes GaugeMetricProducer_test

Test: unit test
Change-Id: Ic60f09342d14cfb107be2130d445b323a56909e0
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
a7259abde4e89fd91404b14b4845113cd313d1ec 10-Dec-2017 Chenjie Yu <cjyu@google.com> use running sum for ValueMetricProducer bucket
simplify ValueMetricProducer logic for pulled data

Test: unit test
Change-Id: Ic0a21a543166cc5c34c1fa505dba08d1fc2f510a
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
80235403d2a80eee1c23dbe856d18194b1b93843 14-Nov-2017 Yao Chen <yaochen@google.com> statsd: parse the new format of stats log

+ Changed how we construct LogEvent, now it's based on the context from log_msg
without making a copy of the list.

+ All stats logs now have the same event tag, the atom id is the first elem in the log.

Test: statsd_test
Change-Id: I4419380f2ee1c2b2155d427b9f2adb78883b337f
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
93fe3a34a02c673eaee4a2d18565ba8df20685cb 02-Nov-2017 Yao Chen <yaochen@google.com> Add unit tests for CountMetricProducer, EventMetricProducer

And other miscellaneous fixes.
+ clang-format
+ 2 bug fixes, one in dump-report command, one in ResourcePowerManagerPuller

Test: statsd_test

Change-Id: Ibd164d948ad62adcc529d813df1210781e38be47
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
a3bf0509e01c6b32a13cfd16060e4a537706f231 02-Nov-2017 David Chen <dwchen@google.com> Fixes LogEvent constructor to use reference.

Previously when fixing LogEvent missing strings because of pointer
lifetime issues, I had the constructor for LogEvent pass log_msg by
value. This fixes log_msg to pass by reference again so that we avoid
wasting memory.

Test: Checked statsd unit-tests still pass.
Change-Id: I94ac4d1bed19fec19d44e27fe94e07ab30383363
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
5110bedd787835d4dbc809b7977285cac364bdef 23-Oct-2017 Yao Chen <yaochen@google.com> Add EventMetricProducer

+ Started to use ProtoOutputStream in EventMetricProducer.
[TODO]: We need to auto-generate fieldIds for StatsLogReport, XXXMetricData, etc.
[TODO]: We need to add Enum type to liblog, otherwise we cannot reconstruct a proto containing
an enum

+ Some refactor in metric initialization code. There are still boiler plate code, because Metrics
are similar but with subtle differences.

Test: statsd_test

Change-Id: Id7e3212566249a8139b9680f04238c455d50c1b8
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
1481fe142d36d5f0b36eeebc358d5a8aef7bf28a 16-Oct-2017 David Chen <dwchen@google.com> Changes pulled data to use Parcel objects.

Previously, pulled data was returned as a string. We instead
return the data as an array of StatsLogEventWrapper, which encodes
using the binary-encoded format liblog uses. StatsD uses the same
parsing as for pushed events to convert these. This CL also fixes
the parsing of log_msg since the strings were previously emptied
before we had a chance to read the values.

Note that the cpp-aidl can't support List of Parcelable, so we
have to return the results as an array.

Test: Manual using the new command in StatsService to print results.
Also created a new unit-test by creating a dummy pull code of -1,
but this test is deleted since it required creating a fake output in
StatsCompanionService.

Change-Id: I1cfb9ea081a59292a60e934e8527adc40982ed80
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
729093df0dd7d7038ad43b16ecdb59a1404f3b50 16-Oct-2017 Yao Chen <yaochen@google.com> Add support for dimension, and link with condition and added DurationMetric

Now we support following metrics:
<Duration> of [app holding a wake lock], while [*this app*] is [in background] [AND] [screen is off]
[Slice] the output by [app name, wake lock name], with bucket size [30sec]

+ Also added onDumpReport() api in MetricsManager, it can be called from client to fetch the data from
statsd

+ Also added command line tool to dump the StatsLogReport from all metrics for debugging.

+ Synced proto from google3. with a pending cl (cr/172359050)

TODO: We need to add tons of tests to test the Metrics. I will work on it after this CL so people
can be unblocked.

I locally test the duration metric with wake lock with an app that generates StatsLog events.

Test: statsd_test

and manual test, and run:

adb shell cmd stats dump-report
We have a default config, which contains a metrics to count PROCESS_START event sliced by
package name.

Change-Id: I4838cc6cf025c143b7e84f43040703a78121fd25
/frameworks/base/cmds/statsd/src/logd/LogEvent.h
c4dfae56c10a1dd571baa78c750f2e68c919d74f 18-Oct-2017 Joe Onorato <joeo@google.com> Introduce a new wrapper for log_msg -- LogEvent

It stores all of the parsed fields in a single vector, and
provides accessor methods to get at fields by index with
their correct type.

Test: statsd_test
Change-Id: I4fa94e4ce52db3ac87f19b62f9c85398de6e8145
/frameworks/base/cmds/statsd/src/logd/LogEvent.h