41 Commits

Author SHA1 Message Date
Igor Murashkin
7ed889c071 iorap: Add script to analyze iorap's compiled TraceFile.
Bug: 150492328
Test: ./analyze_prefetch_file.py -i <path-to-compiled-trace-pb>
Change-Id: I7ba956b34f71d43fbb3f475e618ee67fe0c67740
2020-02-28 15:30:51 -08:00
Igor Murashkin
3fc5e2c322 startop: Fix scripts and add --reportfullydrawn
Fixes a bug in the scripts which prevented true cold starts from
happening (it was force-stopping the activity after the dropcaches).

Also adds -rfd/--reportfullydrawn to make rfd parsing optional since
most apps don't have it.

Bug: 150237362
Test: run_app_with_prefetch -r cold
Change-Id: I132bfc3ccd4d96f171ed364ef64387bbf2c78091
2020-02-25 14:30:45 -08:00
Igor Murashkin
2f54a688c8 startop: Update parse_metrics to parse #ReportFullyDrawn
Change-Id: I0b81c6348aadb19500d174b3b7fba8a7be1c88c5
2020-01-27 14:36:31 -08:00
Yan Wang
54658c9995 startop: Change the ino from decimal to hex in test and an import mistake.
Bug: 142958901
Test: pytest
Change-Id: If9870541561c4099cd255efe0afb66a6e5e02cd0
2019-10-18 13:46:01 -07:00
Yan Wang
d8f8b66585 startop: Fix a compiler type mismatch in test.
Bug: 142958901
Test: pytest
Change-Id: Ifa0b0f85464447a5d50495d35276581176380d90
2019-10-18 13:34:56 -07:00
TreeHugger Robot
bc28861d58 Merge "startop: Only do perfetto trace when needed." 2019-10-10 02:09:34 +00:00
Yan Wang
7c76fcacce startop: Only do perfetto trace when needed.
Bug: 141324324
Test: python app_startup_runner.py  --package com.google.android.GoogleCamera  --readahead fadvise --inodes ../tmp.txt   -d
Test: python app_startup_runner.py  --package com.google.android.GoogleCamera  --readahead cold --inodes ../tmp.txt   -d
Change-Id: Icbf9e253cd3cf9517dca89c8d50efd21012105a9
2019-10-09 17:08:21 -07:00
Yan Wang
87d025efe3 startop: Change the pattern to find the completion of readahead.
The pattern is shown in logcat and should match the text in iorap.

Test: python app_startup_runner.py  --package com.google.android.GoogleCamera  --readahead fadvise --inodes ../tmp.txt   -d
Bug: 142350683
Change-Id: Ia708ea8d29f4c97126e9e721284a0d346e19573b
2019-10-09 16:26:30 -07:00
Yan Wang
90c2b028dc startop: Fix the if condition to prevent duplicate filename for file id
0 in host compiler.

Test: pytest
Bug: 140655545
Change-Id: I952db4cf06060483cfcf8e42352324ad0d710d3b
2019-09-11 14:08:24 -07:00
Yan Wang
75015c32eb startop: add compiler type support to host and device switch.
When using device, the python modules for host are not loaded to be
compatiable in tradefed.

Test: pytest
Test: python app_startup_runner.py --package com.google.android.GoogleCamera --readahead fadvise --inodes textcache --output output.txt -lc 1 -d

Change-Id: I9fe54045fbabda5f66ebe1cfe6d0a5461fff0640
2019-09-10 11:47:23 -07:00
Yan Wang
ab89ecbc82 startop: Fix comments in gerrit CL 9172239.
Test: pytest
Change-Id: I706730c8d54e575e26ff0e2bdbb668d2e70a5c2e
2019-09-03 11:18:15 -07:00
Yan Wang
2ae4f03578 startop: Change trace duration in compiler.py to timedelta.
The time in timestamp is second, while the trace duration is
millisecond. Using timedelta to fix this ambiguity.

Test: pytest compiler_test.py
Change-Id: I6c445c3dac1b60aec77ead14df021b8a2dda7b5e
2019-08-08 18:34:36 -07:00
Yan Wang
6ddab32f68 startop: Add support for trace duration.
Test: pytest app_startup/
Bug: 138233470
Change-Id: Ic8e99b369d3385015d7c86624a61bb6d5e8fdc70
2019-07-31 14:38:40 -07:00
Yan Wang
59aab11f09 startop: Rewrite the perfetto trace collection part.
Test: pytest perfetto_trace_collector_test.py
Bug: 138233615
Change-Id: If13d895029e734a5e52bed73c5f870bb3f036c2f
2019-07-30 19:04:20 -07:00
Yan Wang
06f54882c0 startop: Refactor app running.
Collecting and app running share lots of common code.
Create a new class to run app and allow callbacks to specify
preprocess and postprocess and metrics selection.

Test: pytest run_app_with_prefetch_test.py
Test: pytest app_runner_test.py
Bug: 138233615
Change-Id: I972c82fb9ff3a0f6cc7661bc3dc47b342716c26c
2019-07-30 15:55:18 -07:00
Yan Wang
c50d0fc2b7 startop: Add support to perfetto trace in compiler.py.
Test: pytest compiler_test.py
Bug: 137398235
Change-Id: I6968644d5c44b88e1207dfdaaa379f643d036443
2019-07-22 15:47:22 -07:00
Yan Wang
9104e0553d startop: Add test for compiler.py.
Test: pytest compiler_test.py
Bug: 137398235
Change-Id: I036ed1fee1451176ef854a9a00c460eb0685bafe
2019-07-18 15:49:45 -07:00
Yan Wang
9af1627e57 startop: Add test for trace_analyzer
Test: pytest run_app_with_prefetch_test.py
Bug: 137398235
Change-Id: I19f9e798073a7af1ebc6d668a64782b16cfeeffd
2019-07-18 15:49:33 -07:00
Yan Wang
ef54d7cf20 Fix a failed test because of passing wrong type of arguments.
Test: pytest run_app_with_prefetch_test.py
Change-Id: Id416e67bac8fe3487e5ea85cc488bda0988d513b
2019-07-17 16:07:14 -07:00
Yan Wang
315ae2d4c4 Add support of trace duration for host python compiler.
The basic idea is add timestamp for MmFilemapAddToPageCache.
Treat the first receiving MmFilemapAddToPageCache timestamp as
the start time. The end time is the sum of start time and duration.
Any MmFilemapAddToPageCache after end time is filtered out.

Test: pytest trace2db_test.py
Bug: 137398235
Change-Id: Ib9c439f3ae0ca666eacb08492361217d89adec34
2019-07-17 15:47:54 -07:00
Yan Wang
7af0155c41 startop: Rewrite app startup runner to use new python run_app_with_prefetch.
Test: pytest app_startup_runner_test.py
Test: pytest lib/args_utils_test.py
Test: pytest lib/data_frame_test.py
Test: ./app_startup_runner.py  --package com.google.android.music --readahead fadvise --readahead cold   --inodes textcache  --output output.txt -d -lc 3
Change-Id: Ide9abe4ff3d7179e6830a7866b0eb90cc67d8e40
Bug: 137216480
2019-07-11 11:40:04 -07:00
Yan Wang
3fb2816c59 startop: Rewrite metrics parsing using python.
Shell version metrics parser generates some strange results when called
from Python.

Test: pytest logcat_utils_test.py
Test: pytest adb_utils_test.py
Test: pytest run_app_with_prefetch_test.py
Change-Id: I44a464f7e87f35ecc283c5108577eb33ad394fc6
2019-07-10 16:57:19 -07:00
Yan Wang
34e2dabcf9 startop: Move compiled trace file installation after activity checking (bugfix).
Test: pytest run_app_with_prefetch_test.py
Test: python run_app_with_prefetch.py -p com.android.settings  -i input -d -r fadvise

Bug: 135286022
Change-Id: I06040bb10bfd8edf3f520576c4aed5a28587b142
2019-07-10 16:53:47 -07:00
Yan Wang
90bc5ac1e0 startop: Update to toggle iorapd.readahead.enable.
Test: python run_app_with_prefetch.py  -p com.android.settings -a com.android.settings.Settings -r fadvise -i input --debug --simulate
Test: python run_app_with_prefetch.py  -p com.android.settings -a com.android.settings.Settings -r fadvise -i input
Test: pytest run_app_with_prefetch_test.py

Bug: 135286022
Change-Id: I4576ebb66bc41124e419681a296a47591f1f3d09
2019-07-10 16:20:51 -07:00
TreeHugger Robot
f8122a27dd Merge "startop: Rewrite the run app bash script to python." 2019-06-28 06:25:22 +00:00
Yan Wang
fb9bdd8da3 startop: Rewrite the run app bash script to python.
Test: python run_app_with_prefetch.py  -p com.android.settings -a com.android.settings.Settings -r fadvise -i input --debug --simulate
Test: python run_app_with_prefetch.py  -p com.android.settings -a com.android.settings.Settings -r fadvise -i input
Test: pytest run_app_with_prefetch_test.py

Bug: 135286022
Change-Id: I761e5d20292febcb47b7ca9f87d6847d77250f68
2019-06-27 14:07:03 -07:00
Igor Murashkin
06d017ee19 startop: Add iorap compiler written in python
Compiler will be used for experimentation purpose since it's both easier
to develop in python and it accepts ftrace, making it very easy to write
complicated-experimental changes that we aren't sure are worth it yet
for the on-device C++/perfetto compiler.

This 'new' compiler accepts ftrace/systrace files as input,
then generates an in-memory sqlite3 database (using the trace_analyzer
source code), and finally code-generates a TraceFile.pb protobuf.

(Also refactor trace_analyzer into a library, and update it to
parse systrace.html files)

Limitations: currently does not accept perfetto_trace.pb files due to
             'ofs' fields missing (see bug#135555191)

Test: py.test-3 frameworks/base/startop/scripts
Test: ./compiler.py -i tmp_sargo/textcache -t tmp_sargo/trace.html -o tmp/output.pb
Test: ./compiler.py -i tmp_sargo/textcache -t tmp_sargo/trace.html -o tmp/output.pb -f '^/data'
Test: ./trace_analyzer music_run.trace tmp_dbs/12345.db

Bug: 135557978
Bug: 134789969
Change-Id: Ic8295900ee9e634b4cfd8cf99b671ae08d2ea4f7
2019-06-26 21:19:27 +00:00
TreeHugger Robot
b24a3b1b33 Merge "startop: Update app_startup_runner to toggle iorapd.readahead.enable" 2019-06-26 00:29:10 +00:00
Yan Wang
7eaacb83f4 Fix a DIR missing setting
Test: python app_startup_runner.py  -p com.android.settings -r fadvise --inodes tmp/textcache --debug
Change-Id: I7c5bbfe584451ea650244e737ec9a950368c77be
2019-06-20 15:14:49 -07:00
Igor Murashkin
995c17bdd0 startop: Update app_startup_runner to toggle iorapd.readahead.enable
Bug: 134784018
Change-Id: I6a43696cbdc91542fe3683071850192dfc22b759
Test: manual (run with and without fadvise mode)
2019-06-13 16:42:26 -07:00
TreeHugger Robot
75336f5e08 Merge "startop: Add script to analyze block I/O from an ftrace file" 2019-06-11 05:35:37 +00:00
TreeHugger Robot
5d88587672 Merge "startop: Parse camera metrics from logcat for app_startup_runner" 2019-06-11 01:10:47 +00:00
Igor Murashkin
ab37e6ec2d startop: Parse camera metrics from logcat for app_startup_runner
Parse ACTIVITY_FIRST_PREVIEW_FRAME_RECEIVED_ms,ACTIVITY_FIRST_PREVIEW_FRAME_RENDERED_ms
from logcat when running Camera app.

Also updates the scripts to support multiple metrics output (previously
only one allowed). Adding future per-app metrics is also possible by
just adding 1 file with 1 function call with a regex pattern.

Bug: 132649131
Change-Id: Ibfc620bb156f733b69faa7654b06ef35f1a34de3
2019-06-10 22:20:16 +00:00
Igor Murashkin
0c65d1c5fa startop: Add script to analyze block I/O from an ftrace file
Adds a simple python parser to convert .ftrace file into
sqlite3 database.

The rest of the analysis logic is done through a series of SQL
commands that build tables/views/select queries.

Bug: 134705245
Test: trace_analyzer some_ftrace_file.trace tmp_file.db
Change-Id: I25274e25a0ab1f091ae4e6161e6726e006e346a5
2019-06-10 22:17:13 +00:00
Igor Murashkin
6295fa7339 startop: iorap script to create custom compiled TraceFile
Input: either pinlist.meta or a text file.
Output: either text file or iorap.TraceFile protobuf.

Also supports looking inside zip files to find out entry offset
automatically.

Bug: 132649131
Change-Id: I638fda1bb11899bb6d123b3aaedb518c0b4d1a80
2019-06-10 21:00:44 +00:00
Igor Murashkin
7ab5c4d6e6 startop: Update app_startup_runner to work with iorapd
Script measures app startup times with/without iorapd-based
prefetching against a cold (or warm) baseline.

mlock/fadvise readahead options now use iorapd to exercise
real code to do prefetching.

Bug: 72170747
Change-Id: I28affac3470271e46febb0e22a6dc9543258b4a4
2019-04-24 15:24:25 -07:00
Igor Murashkin
8298ae0039 startop: Add scripts to dump iorap perfetto/compiler protos
Example:
 $> adb pull /data/../iorapd/perfetto_trace.pb
 $> ./dump_trace_pb perfetto_trace.pb

Bug: 72170747
Change-Id: I3901e2c0d8b33ca7a8fa030203180f754514b4ba
2019-04-17 13:56:30 -07:00
Igor Murashkin
973a2dcd6a startop: app_startup script fixes for youtube/chrome
Fix remote_pkill function to work on multiple pids,
this was breaking chrome (which has 3 pids).

Fix activity inference to the "$pkg/$activity"
pattern where previously it could accidentally parse
the wrong token.

Fix app launching to handle activities with '$' in
the name which adb shell treated as a variable.

Test: manual
Change-Id: Ifc9a72f1b9bb5e1416c7602f27f4614efd003849
2018-09-14 16:27:53 -07:00
Igor Murashkin
b622e783ca startop: Make app_startup_runner.py --compiler-filter force compilation
Adds a new script which is used by app_startup_runner.py and
run_app_with_prefetch in order to force the compilation filter.

Example:

  $> ./query_compiler_filter.py --package com.google.android.calculator
  speed-profile unknown arm64

(For example compiling to speed is extremely slow, compiling to
speed-profile is just marginally slow.)

Matching the compiler filter with what we actually need to measure is
extremely important as the performance will vary greatly.

Change-Id: I78ae76504208a672a7d17bab5001d11ab796d9d4
2018-09-13 18:19:26 -07:00
Igor Murashkin
45087deef4 startop: Add script to force dex2oat compilation filter for app
Example: ./force_compiler_filter --package com.google.android.apps.maps --compiler-filter speed-profile

Run the app just slightly enough to fully start up, then force it to
dump the profile and recompile the application with dex2oat under the
speed-profile filter.

(Also supports any other compilation filter such as quicken, speed,
etc).

Subsequently, this command can be used to manually validate that the
compiler filter was indeed changed:

 $ adb shell dumpsys package com.google.android.apps.maps | grep -A10 "Dexopt state"
 Dexopt state:
   [com.google.android.apps.maps]
     path: /data/app/com.google.android.apps.maps-D7s8PLidqqEq7Jc7UH_a5A==/base.apk
       arm64: [status=speed-profile] [reason=unknown]

Test: Manual (see above)
Change-Id: Iea6067f90dc287d1de651d1ab36df69d23b2e9c1
2018-09-13 13:56:58 -07:00
Igor Murashkin
25f394d681 startop: Add app startup measuring scripts
Test: python3 app_startup_runner_test.py
Change-Id: I4a3d0751ff4e3d74ea2937655cbafa5758e2ee1f
2018-09-11 16:43:22 -07:00