Bug 1272851 - Use objdir for temporary directory for mach xpcshell-test; r=ted

When running xpcshell tests on my i7-6700K, the Windows Defender
MsMpEng.exe process regularly consumes up to 50% CPU - 2 whole cores.
This is because it is canning the thousands of files we create in the
temporary directory. (We create a profile for every xpcshell.exe process.)

This commit changes the behavior of `mach xpcshell-test` to use a temporary
directory under the topobjdir. We encourage people to disable file indexing
and A/V scanning in the source and object directories because this can add
overhead. So by putting temporary files in the object directory, we should
minimize the chances of file scanning slowing down test execution.

On my machine (which has Windows Defender disabled in my source and objdirs),
`mach xpcshell-test` execution time drops from ~13:40 to ~7:30. Seriously.

I'm told we have Windows Defender disabled in automation, so this hack
shouldn't need to be investigated there. i.e. this is a pure local development
win.



MozReview-Commit-ID: BMcSAZ16Yei

--HG--
extra : rebase_source : 5490be35b59ff675639180b928ee77dcc70de485
This commit is contained in:
Gregory Szorc 2016-05-26 11:56:20 -07:00
parent e0b7bbc6be
commit 7fd974e58a

View File

@ -7,6 +7,7 @@
from __future__ import absolute_import, unicode_literals, print_function
import argparse
import errno
import os
import shutil
import sys
@ -122,6 +123,18 @@ class XPCShellRunner(MozbuildObject):
if kwargs["failure_manifest"] is None:
kwargs["failure_manifest"] = os.path.join(self.statedir, 'xpcshell.failures.ini')
# Use the object directory for the temp directory to minimize the chance
# of file scanning. The overhead from e.g. search indexers and anti-virus
# scanners like Windows Defender can add tons of overhead to test execution.
# We encourage people to disable these things in the object directory.
temp_dir = os.path.join(self.topobjdir, 'temp')
try:
os.mkdir(temp_dir)
except OSError as e:
if e.errno != errno.EEXIST:
raise
kwargs['tempDir'] = temp_dir
# Python through 2.7.2 has issues with unicode in some of the
# arguments. Work around that.
filtered_args = {}