From 2db05b4b3d209ae184ecb9dccb1d7925c3357abd Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Mon, 16 Jul 2018 14:04:49 -0700 Subject: simpleperf: prefer to use mmap2 records instead of mmap records. When doing system wide recording, simpleperf spents a lot of time in calling ApkInspector::FindElfInApkByOffset() in UpdateMmapRecordForEmbeddedPath() in cmd_record.cpp (about 35% main thread time). This is because app processes map many files in the apk into the memory. Actually we only need to change the maps of executable files in the apk. However, mmap record doesn't show whether the mapped file is executable. So switch to mmap2 record when possible. mmap2 record is supported starting from kernel 3.16, and dumps more info than mmap record, like the protect flag of the map. After switching to mmap2 records, the cost of calling ApkInspector::FindElfInApkByOffset() is decreased to about 1% main thread time. Also switch to dump mmap and comm records only for the first event type. Also avoid using IsRegularFile() in IsMappingOnlyExistInMemory, which saves about 3% main thread time. Also add a test to request mmap2 record support in Q. Bug: none Test: run simpleperf for system wide recording manually. Test: run simpleperf_unit_test. Change-Id: Ib0f42f509cb10b3242503d54d048f9c90885affa --- simpleperf/record.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'simpleperf/record.cpp') diff --git a/simpleperf/record.cpp b/simpleperf/record.cpp index 60ade898..ab2ef72a 100644 --- a/simpleperf/record.cpp +++ b/simpleperf/record.cpp @@ -306,7 +306,7 @@ void Mmap2Record::DumpData(size_t indent) const { ", ino_generation %" PRIu64 "\n", data->pgoff, data->maj, data->min, data->ino, data->ino_generation); - PrintIndented(indent, "prot %u, flags %u, filenames %s\n", data->prot, + PrintIndented(indent, "prot %u, flags %u, filename %s\n", data->prot, data->flags, filename); } -- cgit v1.2.3