Purge unpinned ashmem before parsing /proc/$pid/smaps.

This will help stabilize memory measurements so that memory regressions can't
be hidden when unpinned ashmem gets purged by the kernel.

BUG=311633

Review URL: https://codereview.chromium.org/52833002

git-svn-id: http://src.chromium.org/svn/trunk/src/build@235115 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
pliard@chromium.org 2013-11-14 11:00:30 +00:00
Родитель 76b158ae1b
Коммит 1c4b751d6b
2 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -22,6 +22,9 @@ import time
import cmd_helper
import constants
import screenshot
from utils import host_path_finder
try:
from pylib import pexpect
except:
@ -1418,6 +1421,20 @@ class AndroidCommands(object):
logging.warning('Could not find disk IO stats.')
return None
def PurgeUnpinnedAshmem(self):
"""Purges the unpinned ashmem memory for the whole system.
This can be used to make memory measurements more stable in particular.
"""
host_path = host_path_finder.GetMostRecentHostPath('purge_ashmem')
if not host_path:
raise Exception('Could not find the purge_ashmem binary.')
device_path = os.path.join(constants.TEST_EXECUTABLE_DIR, 'purge_ashmem')
self.PushIfNeeded(host_path, device_path)
if self.RunShellCommand(device_path, log_result=True):
return
raise Exception('Error while purging ashmem.')
def GetMemoryUsageForPid(self, pid):
"""Returns the memory usage for given pid.

Просмотреть файл

@ -0,0 +1,23 @@
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
from pylib import constants
def GetMostRecentHostPath(file_name):
"""Returns the most recent existing full path for the given file name.
Returns: An empty string if no path could be found.
"""
out_dir = os.path.join(
constants.DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'))
candidate_paths = map(
lambda build_type: os.path.join(out_dir, build_type, file_name),
['Debug', 'Release'])
candidate_paths = filter(os.path.exists, candidate_paths)
candidate_paths = sorted(candidate_paths, key=os.path.getmtime, reverse=True)
candidate_paths.append('')
return candidate_paths[0]