diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-14 13:01:01 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-14 13:01:01 +0000 |
commit | 54925d86a10db8f36bab71badfb7b184c70b650b (patch) | |
tree | b9dc200bfe7906a4cb8ad0dbaddd89585578ac34 /build/android/pylib | |
parent | 038d25c1e892494be4b0a96d5257af87248f36b8 (diff) | |
download | chromium_src-54925d86a10db8f36bab71badfb7b184c70b650b.zip chromium_src-54925d86a10db8f36bab71badfb7b184c70b650b.tar.gz chromium_src-54925d86a10db8f36bab71badfb7b184c70b650b.tar.bz2 |
[Telemetry] Speed up page_cycler on android.
Down to 3m22 (without the other optimizations..)
/proc/pid/smaps is kind of large.
It was only used by old style perf tests downstream, long gone
in favor of Telemetry.
Use "showmap %pid" directly, which crunches the data in the device.
Also, while at it, remove GetMemoryUsageForPackage: no longer used.
BUG=
Review URL: https://codereview.chromium.org/280703010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270395 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android/pylib')
-rw-r--r-- | build/android/pylib/android_commands.py | 75 |
1 files changed, 20 insertions, 55 deletions
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py index b5fab46..f2686f1 100644 --- a/build/android/pylib/android_commands.py +++ b/build/android/pylib/android_commands.py @@ -1590,36 +1590,28 @@ class AndroidCommands(object): pid: The pid number of the specific process running on device. Returns: - A tuple containg: - [0]: Dict of {metric:usage_kb}, for the process which has specified pid. + Dict of {metric:usage_kb}, for the process which has specified pid. The metric keys which may be included are: Size, Rss, Pss, Shared_Clean, - Shared_Dirty, Private_Clean, Private_Dirty, Referenced, Swap, - KernelPageSize, MMUPageSize, VmHWM. - [1]: Detailed /proc/[PID]/smaps information. + Shared_Dirty, Private_Clean, Private_Dirty, VmHWM. """ + showmap = self.RunShellCommand('showmap %d' % pid) + if not showmap or not showmap[-1].endswith('TOTAL'): + logging.warning('Invalid output for showmap %s', str(showmap)) + return {} + items = showmap[-1].split() + if len(items) != 9: + logging.warning('Invalid TOTAL for showmap %s', str(items)) + return {} usage_dict = collections.defaultdict(int) - smaps = collections.defaultdict(dict) - current_smap = '' - for line in self.GetProtectedFileContents('/proc/%s/smaps' % pid): - items = line.split() - # See man 5 proc for more details. The format is: - # address perms offset dev inode pathname - if len(items) > 5: - current_smap = ' '.join(items[5:]) - elif len(items) > 3: - current_smap = ' '.join(items[3:]) - if line.endswith('kB'): - key, value = line.split(':') - key = key.strip() - usage_kb = int(value.strip().split()[0]) - usage_dict[key] += usage_kb - if key not in smaps[current_smap]: - smaps[current_smap][key] = 0 - smaps[current_smap][key] += usage_kb - if not usage_dict or not any(usage_dict.values()): - # Presumably the process died between ps and calling this method. - logging.warning('Could not find memory usage for pid ' + str(pid)) - + usage_dict.update({ + 'Size': int(items[0].strip()), + 'Rss': int(items[1].strip()), + 'Pss': int(items[2].strip()), + 'Shared_Clean': int(items[3].strip()), + 'Shared_Dirty': int(items[4].strip()), + 'Private_Clean': int(items[5].strip()), + 'Private_Dirty': int(items[6].strip()), + }) peak_value_kb = 0 for line in self.GetProtectedFileContents('/proc/%s/status' % pid): if not line.startswith('VmHWM:'): # Format: 'VmHWM: +[0-9]+ kB' @@ -1630,34 +1622,7 @@ class AndroidCommands(object): if not peak_value_kb: logging.warning('Could not find memory peak value for pid ' + str(pid)) - return (usage_dict, smaps) - - def GetMemoryUsageForPackage(self, package): - """Returns the memory usage for all processes whose name contains |pacakge|. - - Args: - package: A string holding process name to lookup pid list for. - - Returns: - A tuple containg: - [0]: Dict of {metric:usage_kb}, summed over all pids associated with - |name|. - The metric keys which may be included are: Size, Rss, Pss, Shared_Clean, - Shared_Dirty, Private_Clean, Private_Dirty, Referenced, Swap, - KernelPageSize, MMUPageSize, Nvidia (tablet only). - [1]: a list with detailed /proc/[PID]/smaps information. - """ - usage_dict = collections.defaultdict(int) - pid_list = self.ExtractPid(package) - smaps = collections.defaultdict(dict) - - for pid in pid_list: - usage_dict_per_pid, smaps_per_pid = self.GetMemoryUsageForPid(pid) - smaps[pid] = smaps_per_pid - for (key, value) in usage_dict_per_pid.items(): - usage_dict[key] += value - - return usage_dict, smaps + return usage_dict def ProcessesUsingDevicePort(self, device_port): """Lists processes using the specified device port on loopback interface. |