Bug 1628073 - Remove the view_gecko_profile.py tool; r=sparky,perftest-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D74294
This commit is contained in:
Greg Tatum 2020-05-22 13:19:58 +00:00
parent af96a9bd04
commit 4d20207a95
8 changed files with 10 additions and 251 deletions

View File

@ -46,7 +46,6 @@ exclude =
testing/parse_build_tests_ccov.py,
testing/runtimes/writeruntimes.py,
testing/tools/iceserver/iceserver.py,
testing/tools/view_gecko_profile/view_gecko_profile.py,
testing/tools/websocketprocessbridge/websocketprocessbridge.py,
testing/web-platform,
toolkit/components/featuregates,

View File

@ -704,10 +704,6 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
os.path.basename(_python_interp),
'site-packages')
# If running gecko profiling, install its requirements
if self.gecko_profile:
self._install_view_gecko_profile_req()
sys.path.append(_path)
return
@ -740,10 +736,6 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
'requirements.txt')]
)
# If we're running gecko profiling, install its requirements
if self.gecko_profile:
self._install_view_gecko_profile_req()
def install(self):
if not self.config.get('noinstall', False):
if self.app in self.firefox_android_browsers:
@ -752,17 +744,6 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
else:
super(Raptor, self).install()
def _install_view_gecko_profile_req(self):
# If running locally and gecko profiing is on, we will be using the
# view-gecko-profile tool which has its own requirements too
if self.gecko_profile and self.run_local:
tools = os.path.join(self.config['repo_path'], 'testing', 'tools')
view_gecko_profile_req = os.path.join(tools,
'view_gecko_profile',
'requirements.txt')
self.info("Installing requirements for the view-gecko-profile tool")
self.install_module(requirements=[view_gecko_profile_req])
def _artifact_perf_data(self, src, dest):
if not os.path.isdir(os.path.dirname(dest)):
# create upload dir if it doesn't already exist

View File

@ -570,10 +570,6 @@ class Talos(TestingMixin, MercurialScript, TooltoolMixin,
os.path.basename(_python_interp),
'site-packages')
# if running gecko profiling install the requirements
if self.gecko_profile:
self._install_view_gecko_profile_req()
sys.path.append(_path)
return
@ -603,18 +599,6 @@ class Talos(TestingMixin, MercurialScript, TooltoolMixin,
requirements=[os.path.join(self.talos_path,
'requirements.txt')]
)
self._install_view_gecko_profile_req()
def _install_view_gecko_profile_req(self):
# if running locally and gecko profiing is on, we will be using the
# view-gecko-profile tool which has its own requirements too
if self.gecko_profile and self.run_local:
tools = os.path.join(self.config['repo_path'], 'testing', 'tools')
view_gecko_profile_req = os.path.join(tools,
'view_gecko_profile',
'requirements.txt')
self.info("installing requirements for the view-gecko-profile tool")
self.install_module(requirements=[view_gecko_profile_req])
def _validate_treeherder_data(self, parser):
# late import is required, because install is done in create_virtualenv

View File

@ -6,14 +6,11 @@
from __future__ import absolute_import
import os
import subprocess
import sys
import time
import yaml
from distutils.util import strtobool
from logger.logger import RaptorLogger
from mozgeckoprofiler import view_gecko_profile
LOG = RaptorLogger(component='raptor-utils')
here = os.path.dirname(os.path.realpath(__file__))
@ -64,46 +61,14 @@ def view_gecko_profile_from_raptor():
# automatically load the latest raptor gecko-profile archive in profiler.firefox.com
LOG_GECKO = RaptorLogger(component='raptor-view-gecko-profile')
profile_zip = os.environ.get('RAPTOR_LATEST_GECKO_PROFILE_ARCHIVE', None)
if profile_zip is None or not os.path.exists(profile_zip):
profile_zip_path = os.environ.get('RAPTOR_LATEST_GECKO_PROFILE_ARCHIVE', None)
if profile_zip_path is None or not os.path.exists(profile_zip_path):
LOG_GECKO.info("No local raptor gecko profiles were found so not "
"launching profiler.firefox.com")
return
# need the view-gecko-profile tool, it's in repo/testing/tools
repo_dir = os.environ.get('MOZ_DEVELOPER_REPO_DIR', None)
if repo_dir is None:
LOG_GECKO.info("unable to find MOZ_DEVELOPER_REPO_DIR, can't launch view-gecko-profile")
return
view_gp = os.path.join(repo_dir, 'testing', 'tools',
'view_gecko_profile', 'view_gecko_profile.py')
if not os.path.exists(view_gp):
LOG_GECKO.info("unable to find the view-gecko-profile tool, cannot launch it")
return
command = [sys.executable,
view_gp,
'-p', profile_zip]
LOG_GECKO.info('Auto-loading this profile in perfhtml.io: %s' % profile_zip)
LOG_GECKO.info(command)
# if the view-gecko-profile tool fails to launch for some reason, we don't
# want to crash talos! just dump error and finish up talos as usual
try:
view_profile = subprocess.Popen(command)
# that will leave it running in own instance and let talos finish up
except Exception as e:
LOG_GECKO.info("failed to launch view-gecko-profile tool, exeption: %s" % e)
return
time.sleep(5)
ret = view_profile.poll()
if ret is None:
LOG_GECKO.info("view-gecko-profile successfully started as pid %d" % view_profile.pid)
else:
LOG_GECKO.error('view-gecko-profile process failed to start, poll returned: %s' % ret)
LOG_GECKO.info("Profile saved locally to: %s" % profile_zip_path)
view_gecko_profile(profile_zip_path)
def write_yml_file(yml_file, yml_data):

View File

@ -7,7 +7,6 @@ from __future__ import absolute_import, print_function
import copy
import os
import subprocess
import sys
import time
import traceback
@ -24,6 +23,7 @@ from talos.config import get_configs, ConfigurationError
from talos.results import TalosResults
from talos.ttest import TTest
from talos.utils import TalosError, TalosRegression
from mozgeckoprofiler import view_gecko_profile
# directory of this file
here = os.path.dirname(os.path.realpath(__file__))
@ -348,45 +348,13 @@ function FindProxyForURL(url, host) {
def view_gecko_profile_from_talos():
profile_zip = os.environ.get('TALOS_LATEST_GECKO_PROFILE_ARCHIVE', None)
if profile_zip is None or not os.path.exists(profile_zip):
profile_zip_path = os.environ.get('TALOS_LATEST_GECKO_PROFILE_ARCHIVE', None)
if profile_zip_path is None or not os.path.exists(profile_zip_path):
LOG.info("No local talos gecko profiles were found so not launching profiler.firefox.com")
return
# need the view-gecko-profile tool, it's in repo/testing/tools
repo_dir = os.environ.get('MOZ_DEVELOPER_REPO_DIR', None)
if repo_dir is None:
LOG.info("unable to find MOZ_DEVELOPER_REPO_DIR, can't launch view-gecko-profile")
return
view_gp = os.path.join(repo_dir, 'testing', 'tools',
'view_gecko_profile', 'view_gecko_profile.py')
if not os.path.exists(view_gp):
LOG.info("unable to find the view-gecko-profile tool, cannot launch it")
return
command = ['python',
view_gp,
'-p', profile_zip]
LOG.info('Auto-loading this profile in profiler.firefox.com: %s' % profile_zip)
LOG.info(' '.join(command))
# if the view-gecko-profile tool fails to launch for some reason, we don't
# want to crash talos! just dump error and finsh up talos as usual
try:
view_profile = subprocess.Popen(command)
# that will leave it running in own instance and let talos finish up
except Exception as e:
LOG.info("failed to launch view-gecko-profile tool, exeption: %s" % e)
return
time.sleep(5)
ret = view_profile.poll()
if ret is None:
LOG.info("view-gecko-profile successfully started as pid %d" % view_profile.pid)
else:
LOG.error('view-gecko-profile process failed to start, poll returned: %s' % ret)
LOG.info("Profile saved locally to: %s" % profile_zip_path)
view_gecko_profile(profile_zip_path)
def make_comparison_result(base_and_reference_results):

View File

@ -1,17 +0,0 @@
To use the view_gecko_profile tool:
cd testing/tools/view_gecko_profile
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
Then the command line:
python view_gecko_profile.py -p <path to gecko_profile.zip>
i.e.:
python view_gecko_profile.py -p /Users/rwood/mozilla-unified/testing/mozharness/build/blobber_upload_dir/profile_damp.zip

View File

@ -1 +0,0 @@
mozlog==6.0

View File

@ -1,120 +0,0 @@
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import sys
import argparse
import json
import os
import socket
import sys
import time
import urllib
from threading import Thread
from mozlog import commandline, get_default_logger
from mozlog.commandline import add_logging_group
import SocketServer
import SimpleHTTPServer
here = os.path.abspath(os.path.dirname(__file__))
class ProfileServingHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
"""Extends the basic SimpleHTTPRequestHandler (which serves a directory
of files) to include request headers required by profiler.firefox.com"""
def end_headers(self):
self.send_header("Access-Control-Allow-Origin", "https://profiler.firefox.com")
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
class ViewGeckoProfile(object):
"""Container class for ViewGeckoProfile"""
def __init__(self, gecko_profile_data_path):
self.log = get_default_logger(component='view-gecko-profile')
self.gecko_profile_data_path = gecko_profile_data_path
self.gecko_profile_dir = os.path.dirname(gecko_profile_data_path)
self.profiler_url = "https://profiler.firefox.com/from-url/"
self.httpd = None
self.host = '127.0.0.1'
self.port = None
def setup_http_server(self):
# pick a free port
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 0))
self.port = sock.getsockname()[1]
sock.close()
os.chdir(self.gecko_profile_dir)
self.httpd = SocketServer.TCPServer((self.host, self.port), ProfileServingHTTPRequestHandler)
self.log.info("File server started at: %s:%s" % (self.host, self.port))
def handle_single_request(self):
self.httpd.handle_request()
def encode_url(self):
# Encode url i.e.: https://profiler.firefox.com/from-url/http... (the profile_zip served locally)
url = "http://{}:{}/{}".format(self.host, self.port,
os.path.basename(self.path_to_gecko_profile_data))
self.log.info("raw url is:")
self.log.info(url)
encoded_url = urllib.quote(url, safe='')
self.log.info('encoded url is:')
self.log.info(encoded_url)
self.profiler_url = self.profiler_url + encoded_url
self.log.info('full url is:')
self.log.info(self.profiler_url)
def open_profile_in_browser(self):
# Open the file in the user's preferred browser.
self.log.info("Opening the profile data in profiler.firefox.com...")
import webbrowser
webbrowser.open_new_tab(self.profiler_url)
def create_parser(mach_interface=False):
parser = argparse.ArgumentParser()
add_arg = parser.add_argument
add_arg('-p', '--profile-zip', required=True, dest='profile_zip',
help="path to the gecko profiles zip file to open in profiler.firefox.com")
add_logging_group(parser)
return parser
def verify_options(parser, args):
ctx = vars(args)
if not os.path.isfile(args.profile_zip):
parser.error("{profile_zip} does not exist!".format(**ctx))
def parse_args(argv=None):
parser = create_parser()
args = parser.parse_args(argv)
verify_options(parser, args)
return args
def main(args=sys.argv[1:]):
args = parse_args()
commandline.setup_logging('view-gecko-profile', args, {'tbpl': sys.stdout})
LOG = get_default_logger(component='view-gecko-profile')
view_gecko_profile = ViewGeckoProfile(args.profile_zip)
view_gecko_profile.setup_http_server()
view_gecko_profile.encode_url()
view_gecko_profile.open_profile_in_browser()
view_gecko_profile.handle_single_request()
if __name__ == "__main__":
main()