diff options
author | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-28 23:45:06 +0000 |
---|---|---|
committer | tonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-28 23:45:06 +0000 |
commit | 55af986ccda5f6062717f99a172bb55901d09c93 (patch) | |
tree | 7ec1c93e94250bd263b80488a1573cd64bc9964b /tools/telemetry | |
parent | cc9662f2e777a3246e8285d0d8f7dcf589005f97 (diff) | |
download | chromium_src-55af986ccda5f6062717f99a172bb55901d09c93.zip chromium_src-55af986ccda5f6062717f99a172bb55901d09c93.tar.gz chromium_src-55af986ccda5f6062717f99a172bb55901d09c93.tar.bz2 |
[Telemetry] Parent process must have a creation date older than its children.
After some googling, I learned that windows is more likely to re-use process
IDs and thus the parent process id can be stale. The recommended work around is
to only consider a parent valid if its creation time is prior to the creation
of the child.
BUG=223108
TEST=moz page cyclers on windows
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/13253002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/telemetry')
-rw-r--r-- | tools/telemetry/telemetry/core/chrome/win_platform_backend.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/telemetry/telemetry/core/chrome/win_platform_backend.py b/tools/telemetry/telemetry/core/chrome/win_platform_backend.py index 5a60211..d025aed 100644 --- a/tools/telemetry/telemetry/core/chrome/win_platform_backend.py +++ b/tools/telemetry/telemetry/core/chrome/win_platform_backend.py @@ -101,21 +101,26 @@ class WinPlatformBackend(platform_backend.PlatformBackend): def GetChildPids(self, pid): """Retunds a list of child pids of |pid|.""" - pid_ppid_list = subprocess.Popen(['wmic', 'process', 'get', - 'ParentProcessId,ProcessId'], - stdout=subprocess.PIPE).communicate()[0] - logging.info('wmic process output:\n' + pid_ppid_list) + creation_pid_ppid_list = subprocess.Popen( + ['wmic', 'process', 'get', 'CreationDate,ParentProcessId,ProcessId', + '/format:csv'], + stdout=subprocess.PIPE).communicate()[0] + logging.info('wmic process output:\n' + creation_pid_ppid_list) ppid_map = collections.defaultdict(list) - for pid_ppid in pid_ppid_list.splitlines()[1:]: #skip header - if not pid_ppid: + creation_map = {} + # [3:] To skip 2 blank lines and header. + for creation_pid_ppid in creation_pid_ppid_list.splitlines()[3:]: + if not creation_pid_ppid: continue - curr_ppid, curr_pid = pid_ppid.split() + _, creation, curr_ppid, curr_pid = creation_pid_ppid.split(',') ppid_map[int(curr_ppid)].append(int(curr_pid)) + if creation: + creation_map[int(curr_pid)] = float(creation.split('-')[0]) def _GetChildrenPids(ppid_map, pid): if not pid or pid not in ppid_map: return [] - ret = ppid_map[pid] + ret = [p for p in ppid_map[pid] if creation_map[p] >= creation_map[pid]] for child in ppid_map[pid]: if child == pid: continue |