History log of /system/extras/simpleperf/record.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ada97db3d4336faac601663e8bb4b59835ae49a0 24-Feb-2017 Yabin Cui <yabinc@google.com> simpleperf: generate one report for each event attr.

Bug: http://b/35475170
Test: run simpleperf_unit_test.
Test: run report.py.
Change-Id: Ie9329a64c701bce38f7b440c16cb47e99e83db45
/system/extras/simpleperf/record.cpp
26968e6c48dea2eaa217991ade5a04e801f1be8f 30-Jan-2017 Yabin Cui <yabinc@google.com> simpleperf: add inplace-sampler event type.

Add inplace-sampler event type, so it can be used in
record/list command. This cl doesn't add code for communicating
with profiled process, and fake records in InplaceSamplerClient.cpp
for testing purpose.
Refactor runtest.py to test inplace-sampler profiling.

Bug: http://b/30974760
Test: run runtest.py --inplace-sampler.
Change-Id: I92d8b03583c58b3589207f5c655e03853899be3a
/system/extras/simpleperf/record.cpp
2ea6de11962fea5613f15308b202fb505e57ae9b 25-Oct-2016 Yabin Cui <yabinc@google.com> simpleperf: merge records from different buffers in memory.

By reading records from all buffers at once, we can merge records
in memory instead of sorting them in perf.data. To make it clear,
this patch only contains the code to merge records in memory, and
I will remove old method later.

Bug: http://b/32343227
Test: run simpleperf_unit_test.
Test: run simpleperf_runtest.py.
Change-Id: Iea2da06c072243c2014f43c8aa6d96a23cfb9123
/system/extras/simpleperf/record.cpp
2597ef042881f834d1bc414930f144a405dd13ca 19-Oct-2016 Yabin Cui <yabinc@google.com> simpleperf: support building sample record manually.

And other small changes:
add time when building comm record.
move some Move*BinaryFormat to utils.h.
Handle wrong symbol whoes address can be ULLONG_MAX.

Bug: http://b/30974760
Test: simpleperf_unit_test.
Change-Id: I2956d3c4b781c580fe93a6e5b77e0469f7f4f43f
/system/extras/simpleperf/record.cpp
eafa7188ac41584555d36ac0c19f3c7fc66d42cc 30-Aug-2016 Yabin Cui <yabinc@google.com> simpleperf: fix two errors.

Fix two errors when reporting perf.data generated by linux perf.
And add corresponding tests.

Test: run simpleperf_unit_test.
Change-Id: I04dd88461fdd6a85763847570bac16db1ccb81fa
/system/extras/simpleperf/record.cpp
825e56be3a1c5310969aaa3e10a7cd1f63455189 27-Aug-2016 Yabin Cui <yabinc@google.com> simpleperf: support hotplug events in record cmd.

1. When a cpu is down, read records from event files on that cpu,
then close those event files.
2. When a cpu is up, open event files on that cpu, and create
mapped buffer for those event files to dump records.
3. Instead of creating a mapped buffer for each event type on each
cpu, we can just create a mapped buffer for all event types on
each cpu.
4. When new event files are created, store a EventIdRecord record in
perf.data to notify record_file_reader.cpp.

Bug: http://b/29245608
Test: run simpleperf record cmd and make cpu offline and online.
Test: run simpleperf_unit_test.

Change-Id: Ib97a24b6292fa143e9b35cb105bdddf1e826d60a
/system/extras/simpleperf/record.cpp
fc22b8f4c033a4ab26b864e29308e1b96fe8d712 04-Aug-2016 Yabin Cui <yabinc@google.com> simpleperf: reduce Record construction overhead while recording.

Avoid binary allocation and memory copy in ReadRecordsFromBuffer(),
thus reduce Record construction overhead in
EventSelectionSet::ReadMmapEventDataForFd().

Remove RecordCache used while recording. Replace it with
RecordFileWriter::SortDataSection(). For unwinding while
recording, use low watermark to make records almost sorted
when dumped from the kernel.

Bug: 30649868
Test: run simpleperf_unit_test.

Change-Id: Ie5fb942046900a5960b3c990cf4177c026eaadfb
/system/extras/simpleperf/record.cpp
190a848fb2d4f502372b2528c55ca1f520e90609 04-Aug-2016 Yabin Cui <yabinc@google.com> simpleperf: keep binary in class Record.

It removes memory copy and heap allocation/deallocation in
Record::BinaryFormat(), and is a preparation to remove memory
copy and heap allocation in Record constructor.

Bug: 30649868
Test: run simpleperf_unit_test.
Change-Id: Ic8dd80e43f7b547a9beaf896d726b56aeb5d55a2
/system/extras/simpleperf/record.cpp
c855ecc6becfe5d1c2445094aa525856e4538f7c 12-Jul-2016 Yabin Cui <yabinc@google.com> simpleperf: add min_vaddr in DsoRecord.

Min virtual address of a shared library is needed when mapping ip
addresses to function symbols. So we should dump it in DsoRecord.

Bug: 28114205
Test: run simpleperf_unit_test.

Change-Id: Ib986ee598281cf60caa3a2c5408100b9e7678143
/system/extras/simpleperf/record.cpp
86d934083f5ad968bc2a6dfaa2cfc53d7bafcbc4 06-Jul-2016 Yabin Cui <yabinc@google.com> simpleperf: fix RecordCache.

RecordCache::Push(vector<..>) doesn't update last_time_, this makes
RecordCache don't pop any record before PopAll().

Bug: 29581559
Change-Id: Icea806346b7ad812e606eaf05747797b766ebd71
Test: run simpleperf_unit_test.
/system/extras/simpleperf/record.cpp
1761a271faf98050891ba6e918993225782c811a 24-Jun-2016 Yabin Cui <yabinc@google.com> Simpleperf: Add SPLIT and SPLIT_END records to handle big records.

Previously we split KernelSymbolRecord because it is > 65535. Then
I found TracingDataRecord can also be > 65535. So it is better to
handle big records when reading and writing perf.data.
record_file_writer.cpp splits a big record into multiple SPLIT
records followed by a SPLIT_END record, and record_file_reader.cpp
restores the big record when reading SPLIT and SPLIT_END records.
Also Add RecordHeader to represent record having size > 65535.

Bug: 29581559
Change-Id: I0b4556988f77b3431c7f1a28fce65cf225d6a067
Test: run simpleperf_unit_test.
/system/extras/simpleperf/record.cpp
e5adc13cda8dd413f86d0dc8d187052efcaff7e5 22-Jun-2016 Yabin Cui <yabinc@google.com> Simpleperf: report lost record count and warn if 10% records are lost.

Bug: 29126335
Change-Id: Id4a5b51120389387ec3ab45ea9ad9a276aa6ce2a
Test: run simpleperf with high -f option and check the lost record warning.
/system/extras/simpleperf/record.cpp
a7a0e5076f0107173bc9ee067d13955d0d169f25 15-Jun-2016 Yabin Cui <yabinc@google.com> simpleperf: replace SIMPLEPERF_ALIGN macro with Align inline function.

Change-Id: Id9e9e67174ab3f857eb2baa9609351b60586b8dd
/system/extras/simpleperf/record.cpp
b54c5e5e3d6529a7363e5493745a6bbcf30b964f 14-Jun-2016 Yabin Cui <yabinc@google.com> simpleperf: fix mac build.

Bug: 28114205
Change-Id: I84ad011b10c19e07576b718ba4b6b6c52a823366
/system/extras/simpleperf/record.cpp
4f41df6f68efc3b9b534014a8cfb6ee8ac4d5c91 02-Jun-2016 Yabin Cui <yabinc@google.com> simpleperf: dump tracing data when needed.

When monitoring tracepoint events, dump tracing data to perf.data
can enable reporting on a different machine.

Bug: 27403614
Change-Id: Ie1af624717a245cacbeb44b4c1bcd499fc9ad8db
/system/extras/simpleperf/record.cpp
767dd17947f1ae9dd3d02f738d442a23ed76f2f6 03-Jun-2016 Yabin Cui <yabinc@google.com> simpleperf: add report-sample command.

1. Add report-sample command to report each sample with symbol information.
2. Add --dump-symbols option to record command to collect dso and symbol
information in perf.data.

Bug: 28114205

Change-Id: I37424ee6abd74a21ad41cd3b6c4249cf0625c201
/system/extras/simpleperf/record.cpp
b42129797f17f990ea5a88c6bdc7446000cc361c 25-May-2016 Yabin Cui <yabinc@google.com> simpleperf: record kernel symbols in perf.data.

To better support kernel profiling, record kernel symbols in perf.data
when necessary. An option --no-dump-kernel-symbols is added in
record command to always avoid recording kernel symbols.
The way to handle all zero /proc/modules and /proc/kallsyms is
improved. Add Better support in finding symbols for kernel modules.

Bug: 27403614
Change-Id: I470151c54f8a45ad1c101c1b94490e33d7fd7485
/system/extras/simpleperf/record.cpp
2d6efe4b167da4e6b77f168b1820239ee65599e2 02-Apr-2016 Yabin Cui <yabinc@google.com> simpleperf: support reporting more than one event type.

When sampling kernel trace points, it is like to sample more than
one even type. Like `simpleperf record -e kmem:mm_page_alloc,kmem:mm_page_free`.

1. change record command to dump event_id for all records.
2. change report command and record reader to support multiple
event attrs.
3. hide record_cache inside EventSelectionSet.
4. add test to report multiple event types.

Bug: 27403614
Change-Id: Ic22a5527d68e7a843e3cf95e85381f8ad6bcb196
/system/extras/simpleperf/record.cpp
48460892306fbc232d7623b1aa5be1aefdc1a8a7 18-Mar-2016 Yabin Cui <yabinc@google.com> Simpleperf: remove dependency on global current_arch.

When running unit tests on arm64 devices:
[OK] ReportCommandTest.dwarf_callgraph
[OK] record_cmd.dwarf_callchain_sampling.
ERROR: can't unwind data recorded on a different architecture.

It is because ReportCommandtest.dwarf_callgraph opens a perf.data
recorded on x86_64, and changes current_arch. It causes a problem when
the test record_cmd.dwarf_callchain_sampling calls libbacktrace built
on aarch64. Athough it doesn't make the test fail, we should fix this.

Change-Id: I2cd70369a769ef2199cab2302b8b824369be0907
/system/extras/simpleperf/record.cpp
d4f6a85c3bce576c37aa1ae7af1d9d99bc750197 01-Mar-2016 Yabin Cui <yabinc@google.com> simpleperf: fix analyzer warning.

Bug: 27432175
Change-Id: If0e8bc724cf659508726215d515d3df30cbebe6b
/system/extras/simpleperf/record.cpp
6e51bef9aa101307523946df301ca90215d0ee82 24-Feb-2016 Yabin Cui <yabinc@google.com> simpleperf: port cmd_report_test to nonlinux.

And fix one build_id bug introduced by previous patch.

Bug: 26962895

Change-Id: Ibb8bd6ec77ee862bb01c26342d3b3024468e75b2
/system/extras/simpleperf/record.cpp
b1a885b014540a2f7798b5a35ea0f0ec150d93ee 15-Feb-2016 Yabin Cui <yabinc@google.com> simpleperf: report symbols of native libraries in apk file.

Changes included:
1. provide interface in read_apk.h to read build id and symbols.
2. report symbols of native libraries in apk file.
3. refactor code in read_elf.cpp and read_apk.cpp.
4. add verbose log.
5. add -o report_file_name option for report command.
6. add corresponding unit tests.

Bug: 26962895
Change-Id: I0d5398996e0c29dba4a6f5226692b758ca096bbd
/system/extras/simpleperf/record.cpp
f831e6d12ca2298cb34b155a9d91ef002d0482f3 02-Feb-2016 Than McIntosh <thanm@google.com> Support profiling of shared libs embedded in APKs.

Some APKs contain shared libraries that the linker handles
by mmap'ing directly from their APKs (if the library is
uncompressed and the proper manifest flag is set). With
this patch simpleperf now breaks out samples on a per-li
basis and reports the name of the lib within the APK.
Example output:

Cmdline: /system/xbin/simpleperf record -a sleep 30
Samples: 140672 of event 'cpu-cycles'
Event count: 84111474884

Overhead Command Pid Tid Shared Object
90.22% b_open_from_apk 19066 19066
/data/app/com.android.frameworks.coretests.install_jni_lib_open_from_apk-2/base.apk!lib/armeabi-v7a/libgcdstuff.so
4.85% b_open_from_apk 19066 19066
/data/app/com.android.frameworks.coretests.install_jni_lib_open_from_apk-2/base.apk!lib/armeabi-v7a/libframeworks_coretests_jni.so
1.19% simpleperf 19085 19085 /system/lib/libc.so
...

Bug: 22560619
Change-Id: I1e0f2e155e03b33935eac24e104c3fd7b9a7e33c
/system/extras/simpleperf/record.cpp
4913c12f341bc4319d243af24fa2ee1a6618eb34 12-Jan-2016 Yabin Cui <yabinc@google.com> Simpleperf: adjust sort strategy in RecordCache.

In order to report correctly, We should keep the order of self created
records when reading perf.data. So adjust sort strategy in RecordCache
to avoid reordering it.

Bug: 26214604
Change-Id: I40812ee5f4f6051103d40459edf4b4a2d7a80313
/system/extras/simpleperf/record.cpp
66dd09e8e2407082ce93bf0784de641298131912 04-Dec-2015 Elliott Hughes <enh@google.com> Track rename from base/ to android-base/.

Change-Id: Ic15d4778c7accd1382de0b440a437aba2cf67016
/system/extras/simpleperf/record.cpp
b7f481f59126456b0e708a76f40fa88224f3531b 24-Oct-2015 Yabin Cui <yabinc@google.com> Simpleperf: Don't load whole perf.data into memory.

perf.data can be too large to be loaded into memory.
To avoid this, use fread() instead of mmap() to read perf.data,
and always use RecordCache to sort records.

Fix unit tests failure caused by previous change.

Bug: 25194400

Change-Id: If29dc0bb0ed992ba34202c2cb1a204a1d9123b7a
/system/extras/simpleperf/record.cpp
f469c3d7f4466a2a31c3e837969c43c1e3bc4c90 08-Oct-2015 Yabin Cui <yabinc@google.com> Simpleperf: do stack unwinding while recording.

Dumping user's stack consumes lots of disk space, which makes long period recording
impossible. This patch does stack unwinding before writing to perf.data, so it doesn't
need to save user's stack. Previous behavior is still supported with --post-unwind option.

A record cache is used for online record processing.

Bug: 22229391
Change-Id: Idcc6ec46924fff3fcc8c165d62f8af875b173cd4
/system/extras/simpleperf/record.cpp
cb84c9885e7a9f82cefba566d74e5c71214ab4c9 01-Oct-2015 Yabin Cui <yabinc@google.com> Simpleperf: do dwarf unwinding in record command.

As libbacktrace only supports unwinding for the same architecture it is running on, simpleperf
report command running on host can't unwind perf.data collected on device. So we'd better do
unwinding work in record command on device.

Bug: 22229391
Change-Id: I085ca074ea83dab79f08563523bdbc7a36650a64
/system/extras/simpleperf/record.cpp
bfc11b6c1cf93615c00f3503774dd8f4e3b30172 19-Aug-2015 Yabin Cui <yabinc@google.com> Simpleperf: add raw data in sample records for tracepoint events.

tracepoint events store tracing info in raw data in sample records.
And we need to enable it in sample_type.

Change-Id: Icd866059f4703b56724845d7526ae58099e83113
/system/extras/simpleperf/record.cpp
73d8078e6e5ef92b2301386ce96260bd99efacbb 24-Jul-2015 Yabin Cui <yabinc@google.com> Simpleperf: use ThreadTree when getting hit files in record command.

The new method is more accurate and has lower time complexity.

Bug: 22229391
Change-Id: I8b3016798b8a0e20335adeb7ec5dda0068044142
/system/extras/simpleperf/record.cpp
76769e502d8f0ebf5d2c81b00246727fb0a59925 13-Jul-2015 Yabin Cui <yabinc@google.com> Simpleperf: Support dwarf callgraph recording.

1. add OS_RELEASE and ARCH feature in perf.data. ARCH feature is used when parsing
recorded user registers.
2. support `--call-graph dwarf` option in record command.

Bug: 22229391
Change-Id: I56dbdd101338658ce6a9b59aa8be90e712e007f5
/system/extras/simpleperf/record.cpp
638c558339b7f1ae0ed95f64bcf7dbc5b238ed83 02-Jul-2015 Yabin Cui <yabinc@google.com> Simpleperf: check build id in report command.

1. refactor BuildId type.
2. check build id before parsing symbols in report command.

Bug: 22179177

Change-Id: Iefc797a88d4a168e109db786105120c8d6914369
/system/extras/simpleperf/record.cpp
d713f959ec1fe07ed993e2c9f4166b52aa98a58c 24-Jun-2015 Yabin Cui <yabinc@google.com> Simpleperf: support cmdline feature in perf.data.

Bug: 19483574
Change-Id: I92f16d6616f274f31ea54e305fe1de10049baf02
/system/extras/simpleperf/record.cpp
8a530e3bae0cc031d60e397c347e96f44487e919 24-Jun-2015 Yabin Cui <yabinc@google.com> Simpleperf: add option to report branch stack information.

Bug: 19483574
Change-Id: If98e6d3e7a171bb4f2aa7f5d4be43586a6286f56
/system/extras/simpleperf/record.cpp
41d4ba9f6f2781155a0519a784606d5382cda88f 22-Jun-2015 Yabin Cui <yabinc@google.com> Simpleperf: better support for per thread comm.

1. Move ProcessEntry to ThreadEntry, and add thread_comm in SampleEntry.
2. Add support of ForkRecord and Mmap2Record.
3. Dump ForkRecord for each thread in record command.
4. Add sort key 'tid' in report command, and change default keys.

Bug: 19483574
Change-Id: Iacc690637154aeb7b6f85373730beb50d638ce86
/system/extras/simpleperf/record.cpp
6e8a9a4e52242f82104644bca0318284b3bbdd6b 15-Jun-2015 Yabin Cui <yabinc@google.com> Simpleperf: support callchain sampling in record command.

Bug: 19483574
Change-Id: Icd8ed7c316144fc51d54f196872061533bdeef2b
/system/extras/simpleperf/record.cpp
ddddc06d1f1d15d49e1eb43201b73beb29cf4cde 03-Jun-2015 Yabin Cui <yabinc@google.com> Simpleperf: support branch stack sampling in `simpleperf record`.

This only adds support in simpleperf. Branch stack sampling still
lacks kernel support on arm devices.
Use perf_event.h of bionic in host build, because the perf_event.h
of platform glibc is too old.

Bug: 19483574
Change-Id: I9c7332c054e93e7433717dd293d3f366b1802e2d
/system/extras/simpleperf/record.cpp
f569b478e74560a2d9e29a96824e16b93a55b97f 30-Apr-2015 Yabin Cui <yabinc@google.com> Support tracepoint event types in simpleperf.

Also support options in `simpleperf list`, add test about tracepoint event types.

Bug: 19483574

Change-Id: I2d2c2f300fe5e2968696228899084410aa9f29a4
/system/extras/simpleperf/record.cpp
8f6225147c5b6cb2159a7f5cb0dab952ee0759df 06-May-2015 Yabin Cui <yabinc@google.com> Dump build_id feature in `simpleperf record`.

Bug: 19483574
Change-Id: Ie2acd8a157bca9ad3c01a2e4b37e139aba89670f
/system/extras/simpleperf/record.cpp
7d59bb49fb47fbc82ef5c77d7aebf7174fd996e1 05-May-2015 Yabin Cui <yabinc@google.com> Dump kernel/modules/thread mmap information in `simpleperf record`.

Bug: 19483574
Change-Id: Ia65cb12804a6dffa440501736a6229b2f7248958
/system/extras/simpleperf/record.cpp
9759e1b1ce76185aa539aeea2fb1cbd8382156e7 29-Apr-2015 Yabin Cui <yabinc@google.com> Implement simpleperf record/dumprecord subcommands.

Bug: 19483574

Change-Id: Id879713a75c2d3a6289d8847b95ee0bb4a2cc8a0
/system/extras/simpleperf/record.cpp