Bug 1628982 - Activate the condprofile on desktop + GV r=Bebe,perftest-reviewers

Activates the conditioned profile by doing the following changes:

- make sure the conditioned profile dir is removed after
  it's been used, not before.
- add the --project option to raptor so we know if we're on try
  or mozilla-central.
- Both Fennec and Fenix are deactivated for now.
- Remove any gfx.blacklist.* prefs when using a conditioned profile

Differential Revision: https://phabricator.services.mozilla.com/D70518

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tarek Ziadé 2020-04-14 08:32:13 +00:00
Родитель 68d9c71f19
Коммит 410faf3d47
12 изменённых файлов: 94 добавлений и 15 удалений

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

@ -276,6 +276,8 @@ def add_extra_options(config, tests):
if test['require-signed-extensions']:
extra_options.append('--is-release-build')
extra_options.append("--project={}".format(config.params.get('project')))
# add urlparams based on platform, test names and projects
testurlparams_by_platform_and_project = {
"android-hw-g5": [

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

@ -12,6 +12,8 @@ import tempfile
import shutil
import time
from mozprofile.prefs import Preferences
from condprof import check_install # NOQA
from condprof import progress
from condprof.util import download_file, TASK_CLUSTER, logger, ArchiveNotFound
@ -36,6 +38,25 @@ class ProfileNotFoundError(Exception):
pass
def _check_profile(profile_dir):
"""Checks for GFX black list prefs to make sure none is set
"""
def keep_pref(name, value):
if name.startswith("gfx.blacklist."):
logger.info("Removing pref %s: %s" % (name, value))
return False
return True
prefs_js = os.path.join(profile_dir, "prefs.js")
prefs = Preferences.read_prefs(prefs_js)
cleaned_prefs = [pref for pref in prefs if keep_pref(*pref)]
if len(prefs) == len(cleaned_prefs):
return
with open(prefs_js, "w") as f:
Preferences.write(f, cleaned_prefs)
def get_profile(
target_dir,
platform,
@ -109,6 +130,8 @@ def get_profile(
finally:
if not download_cache:
shutil.rmtree(download_dir)
_check_profile(target_dir)
logger.info("Success, we have a profile to work with")
return target_dir
except Exception:

Двоичные данные
testing/condprofile/condprof/tests/profile.tgz

Двоичный файл не отображается.

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

@ -6,6 +6,8 @@ import responses
import re
import json
from mozprofile.prefs import Preferences
from condprof.client import get_profile, ROOT_URL
from condprof.util import _DEFAULT_SERVER
@ -85,6 +87,12 @@ class TestClient(unittest.TestCase):
# even the TC secret
self.assertEqual(len(responses.calls), 1)
# check that the gfx.blacklist prefs where cleaned out
prefs_js = os.path.join(self.target, "prefs.js")
prefs = Preferences.read_prefs(prefs_js)
for name, value in prefs:
self.assertFalse(name.startswith("gfx.blacklist"))
if __name__ == "__main__":
try:

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

@ -204,6 +204,13 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
"help": "The number of times a cold load test is repeated (for cold load tests only, "
"where the browser is shutdown and restarted between test iterations)."
}],
[["--project"], {
"action": "store",
"dest": "project",
"default": "mozilla-central",
"type": "str",
"help": "Name of the project (try, mozilla-central, etc.)"
}],
[["--test-url-params"], {
"action": "store",
"dest": "test_url_params",

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

@ -217,7 +217,7 @@ class Browsertime(Perftest):
])
# have browsertime use our newly-created conditioned-profile path
if not self.no_condprof:
if self.using_condprof:
self.profile.profile = self.conditioned_profile_dir
if self.config["gecko_profile"]:

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

@ -136,7 +136,9 @@ def create_parser(mach_interface=False):
help='How long to wait (ms) after browser start-up before starting the tests')
add_arg('--browser-cycles', dest="browser_cycles", type=int,
help="The number of times a cold load test is repeated (for cold load tests only, "
"where the browser is shutdown and restarted between test iterations)")
"where the browser is shutdown and restarted between test iterations)"),
add_arg('--project', dest='project', type=str, default='mozilla-central',
help="Project name (try, mozilla-central, etc.)"),
add_arg('--test-url-params', dest='test_url_params',
help="Parameters to add to the test_url query string")
add_arg('--print-tests', action=_PrintTests,

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

@ -95,9 +95,12 @@ either Raptor or browsertime."""
device_name=None,
disable_perf_tuning=False,
extra_prefs={},
project="mozilla-central",
**kwargs
):
self._dirs_to_remove = []
# Override the magic --host HOST_IP with the value of the environment variable.
if host == "HOST_IP":
host = os.environ["HOST_IP"]
@ -126,19 +129,26 @@ either Raptor or browsertime."""
"enable_fission": extra_prefs.get("fission.autostart", False),
"disable_perf_tuning": disable_perf_tuning,
"extra_prefs": extra_prefs,
"project": project
}
self.firefox_android_apps = FIREFOX_ANDROID_APPS
# See bugs 1582757, 1606199, and 1606767; until we support win10-aarch64,
# fennec_aurora, and reference browser conditioned-profile builds,
# fall back to mozrunner-created profiles
self.no_condprof = (
self.using_condprof = not (
(self.config["platform"] == "win" and self.config["processor"] == "aarch64")
or self.config["binary"] == "org.mozilla.fennec_aurora"
or self.config["binary"] == "org.mozilla.reference.browser.raptor"
or self.config["binary"] == "org.mozilla.firefox"
or self.config["binary"].startswith("org.mozilla.fenix")
or self.config["no_conditioned_profile"]
)
LOG.info("self.no_condprof is: {}".format(self.no_condprof))
if self.using_condprof:
LOG.info("Using a conditioned profile.")
else:
LOG.info("Using an empty profile.")
self.config["using_condprof"] = self.using_condprof
# We can never use e10s on fennec
if self.config["app"] == "fennec":
@ -170,7 +180,7 @@ either Raptor or browsertime."""
# For the post startup delay, we want to max it to 1s when using the
# conditioned profiles.
if not self.no_condprof and not self.run_local:
if self.using_condprof and not self.run_local:
self.post_startup_delay = min(post_startup_delay, POST_DELAY_CONDPROF)
else:
# if running debug-mode reduce the pause after browser startup
@ -187,6 +197,11 @@ either Raptor or browsertime."""
# Crashes counter
self.crashes = 0
def _get_temp_dir(self):
tempdir = tempfile.mkdtemp()
self._dirs_to_remove.append(tempdir)
return tempdir
@property
def is_localhost(self):
return self.config.get("host") in ("localhost", "127.0.0.1")
@ -196,7 +211,7 @@ either Raptor or browsertime."""
condprofile client API; returns a self.conditioned_profile_dir"""
# create a temp file to help ensure uniqueness
temp_download_dir = tempfile.mkdtemp()
temp_download_dir = self._get_temp_dir()
LOG.info(
"Making temp_download_dir from inside get_conditioned_profile {}".format(
temp_download_dir
@ -214,12 +229,26 @@ either Raptor or browsertime."""
platform = get_current_platform()
LOG.info("Platform used: %s" % platform)
# when running under mozharness, the --project value
# is set to match the project (try, mozilla-central, etc.)
# By default it's mozilla-central, even on local runs.
# We use it to prioritize conditioned profiles indexed
# into the same project when it runs on the CI
repo = self.config["project"]
# we fall back to mozilla-central in all cases. If it
# was already mozilla-central, we fall back to try
alternate_repo = "mozilla-central" if repo != "mozilla-central" else "try"
LOG.info("Getting profile from project %s" % repo)
try:
cond_prof_target_dir = get_profile(temp_download_dir, platform, "settled")
except ProfileNotFoundError:
# If we can't find the profile on mozilla-central, we look on try
cond_prof_target_dir = get_profile(
temp_download_dir, platform, "settled", repo="try"
temp_download_dir, platform, "settled", repo=repo)
except ProfileNotFoundError:
LOG.info("Profile not found for project %s" % repo)
LOG.info("Getting profile from project %s" % alternate_repo)
cond_prof_target_dir = get_profile(
temp_download_dir, platform, "settled", repo=alternate_repo
)
except Exception:
# any other error is a showstopper
@ -245,12 +274,10 @@ either Raptor or browsertime."""
self.conditioned_profile_dir
)
)
shutil.rmtree(temp_download_dir)
return self.conditioned_profile_dir
def build_browser_profile(self):
if self.no_condprof or self.config['app'] in ['chrome', 'chromium', 'chrome-m']:
if not self.using_condprof or self.config['app'] in ['chrome', 'chromium', 'chrome-m']:
self.profile = create_profile(self.profile_class)
else:
self.get_conditioned_profile()
@ -375,9 +402,13 @@ either Raptor or browsertime."""
def check_for_crashes(self):
pass
@abstractmethod
def clean_up(self):
pass
for dir_to_rm in self._dirs_to_remove:
if not os.path.exists(dir_to_rm):
continue
LOG.info("Removing temporary directory: {}".format(dir_to_rm))
shutil.rmtree(dir_to_rm, ignore_errors=True)
self._dirs_to_remove = []
def get_page_timeout_list(self):
return self.results_handler.page_timeout_list

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

@ -133,6 +133,7 @@ def main(args=sys.argv[1:]):
device_name=args.device_name,
no_conditioned_profile=args.no_conditioned_profile,
disable_perf_tuning=args.disable_perf_tuning,
project=args.project
)
except Exception:
traceback.print_exc()

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

@ -81,6 +81,7 @@ class WebExtensionAndroid(PerftestAndroid, WebExtension):
args=[
"--profile",
self.remote_profile,
"--allow-downgrade",
"use_multiprocess",
self.config["e10s"],
],
@ -127,6 +128,7 @@ class WebExtensionAndroid(PerftestAndroid, WebExtension):
extra_args = [
"-profile", self.remote_profile,
"--allow-downgrade",
"--es", "env0",
"LOG_VERBOSE=1",
"--es", "env1",

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

@ -35,6 +35,7 @@ class WebExtension(Perftest):
self.cpu_profiler = None
super(WebExtension, self).__init__(*args, **kwargs)
self.using_condprof = self.config.get("using_condprof", True)
# set up the results handler
self.results_handler = RaptorResultsHandler(

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

@ -28,10 +28,12 @@ class WebExtensionDesktop(PerftestDesktop, WebExtension):
LOG.info("creating browser runner using mozrunner")
self.output_handler = OutputHandler()
process_args = {"processOutputLine": [self.output_handler]}
firefox_args = ["--allow-downgrade"]
runner_cls = runners[self.config["app"]]
self.runner = runner_cls(
self.config["binary"],
profile=self.profile,
cmdargs=firefox_args,
process_args=process_args,
symbols_path=self.config["symbols_path"],
)