diff options
author | hyunki.baik@samsung.com <hyunki.baik@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-27 13:56:22 +0000 |
---|---|---|
committer | hyunki.baik@samsung.com <hyunki.baik@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-27 13:56:22 +0000 |
commit | 3d44113512698c3af547bbe602a15849828d8dc4 (patch) | |
tree | 983591b57f6ad37658a9b7c4dd146480b175d354 /tools/android | |
parent | 53540181343f7d278f9b8192d0a4b4ea3bb5ff22 (diff) | |
download | chromium_src-3d44113512698c3af547bbe602a15849828d8dc4.zip chromium_src-3d44113512698c3af547bbe602a15849828d8dc4.tar.gz chromium_src-3d44113512698c3af547bbe602a15849828d8dc4.tar.bz2 |
Optimize execution time of the memdump tool
In GalaxyNote3 device, the execution time of memdump takes 5.3s.
Among overall time, GetPagesForMemoryMap function took more than 4s.
This patch removes unnecessary divisions and lseek operations for the hot loop in GetPagesForMemoryMap.
It reduced the execution time from 5.3s to 4.7s on the GalaxyNote3.
BUG=none
Review URL: https://codereview.chromium.org/177003017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/android')
-rw-r--r-- | tools/android/memdump/memdump.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/android/memdump/memdump.cc b/tools/android/memdump/memdump.cc index 50a5914..20684f6 100644 --- a/tools/android/memdump/memdump.cc +++ b/tools/android/memdump/memdump.cc @@ -200,15 +200,22 @@ bool GetPagesForMemoryMap(int pagemap_fd, const MemoryMap& memory_map, std::vector<PageInfo>* committed_pages, BitSet* committed_pages_bits) { + const off64_t offset = memory_map.start_address / kPageSize; + if (lseek64(pagemap_fd, offset * sizeof(PageMapEntry), SEEK_SET) < 0) { + PLOG(ERROR) << "lseek"; + return false; + } for (uint addr = memory_map.start_address, page_index = 0; addr < memory_map.end_address; addr += kPageSize, ++page_index) { DCHECK_EQ(0, addr % kPageSize); PageMapEntry page_map_entry = {}; COMPILE_ASSERT(sizeof(PageMapEntry) == sizeof(uint64), unexpected_size); - const off64_t offset = addr / kPageSize; - if (!ReadFromFileAtOffset(pagemap_fd, offset, &page_map_entry)) + ssize_t bytes = read(pagemap_fd, &page_map_entry, sizeof(page_map_entry)); + if (bytes != sizeof(PageMapEntry) && bytes != 0) { + PLOG(ERROR) << "read"; return false; + } if (page_map_entry.present) { // Ignore non-committed pages. if (page_map_entry.page_frame_number == 0) continue; |