Title: [290811] trunk/Tools
Revision
290811
Author
[email protected]
Date
2022-03-03 18:40:59 -0800 (Thu, 03 Mar 2022)

Log Message

'run-benchmark' script should log http requests during benchmark run.
https://bugs.webkit.org/show_bug.cgi?id=237076
<rdar://89270825>

Reviewed by Jonathan Bedard.

Relanding 290583 with fix.
Add support to log http requests during benchmark run for diagnostic purpose.
AutoInstall sets 'AUTOINSTALL_CA_CERT_PATH' to environment variables when certificate is specified,
and uses 'AUTOINSTALL_CA_CERT_PATH' when it's present in environment variables. This ensures scripts invoked
from subprocess can use autoinstalled correcctly.

* Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
(AutoInstall):
(AutoInstall.set_index):
* Scripts/webkitpy/__init__.py: Update 'attr' package version to 20.3.0 so match upgraded twisted version
* Scripts/webkitpy/autoinstalled/twisted.py: Upgrade twisted version to latest python2 & python3 compatibile
version with specified implicit dependencies.
* Scripts/webkitpy/benchmark_runner/benchmark_runner.py: Ensure benchmark diagnostic directory is created.
(BenchmarkRunner.__init__):
* Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py: Add '--log-path'
arugment to allow specify logging output and it defaults to '/tmp/run-benchmark-http.log'
* Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py:
(HTTPServerDriver.set_device_id):
(HTTPServerDriver):
(HTTPServerDriver.set_http_log):
* Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py: Pass http log path to
twisted http server if specified.
(SimpleHTTPServerDriver.__init__):
(SimpleHTTPServerDriver.serve):
(SimpleHTTPServerDriver.set_http_log):
* Scripts/webkitpy/benchmark_runner/run_benchmark.py: Fix a tiny bug that default_diagnose_dir() is involked twice in
argument parser help message.
(config_argument_parser):
* Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py: Set http request log path if diagnostic directory
is specified.
(WebServerBenchmarkRunner.__init__):

Canonical link: https://commits.webkit.org/248047@main

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (290810 => 290811)


--- trunk/Tools/ChangeLog	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/ChangeLog	2022-03-04 02:40:59 UTC (rev 290811)
@@ -1,3 +1,43 @@
+2022-03-03  Dewei Zhu  <[email protected]>
+
+        'run-benchmark' script should log http requests during benchmark run.
+        https://bugs.webkit.org/show_bug.cgi?id=237076
+        <rdar://89270825>
+
+        Reviewed by Jonathan Bedard.
+
+        Relanding 290583 with fix.
+        Add support to log http requests during benchmark run for diagnostic purpose.
+        AutoInstall sets 'AUTOINSTALL_CA_CERT_PATH' to environment variables when certificate is specified,
+        and uses 'AUTOINSTALL_CA_CERT_PATH' when it's present in environment variables. This ensures scripts invoked
+        from subprocess can use autoinstalled correcctly.
+
+        * Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
+        (AutoInstall):
+        (AutoInstall.set_index):
+        * Scripts/webkitpy/__init__.py: Update 'attr' package version to 20.3.0 so match upgraded twisted version
+        * Scripts/webkitpy/autoinstalled/twisted.py: Upgrade twisted version to latest python2 & python3 compatibile
+        version with specified implicit dependencies.
+        * Scripts/webkitpy/benchmark_runner/benchmark_runner.py: Ensure benchmark diagnostic directory is created.
+        (BenchmarkRunner.__init__):
+        * Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py: Add '--log-path'
+        arugment to allow specify logging output and it defaults to '/tmp/run-benchmark-http.log'
+        * Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py:
+        (HTTPServerDriver.set_device_id):
+        (HTTPServerDriver):
+        (HTTPServerDriver.set_http_log):
+        * Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py: Pass http log path to
+        twisted http server if specified.
+        (SimpleHTTPServerDriver.__init__):
+        (SimpleHTTPServerDriver.serve):
+        (SimpleHTTPServerDriver.set_http_log):
+        * Scripts/webkitpy/benchmark_runner/run_benchmark.py: Fix a tiny bug that default_diagnose_dir() is involked twice in
+        argument parser help message.
+        (config_argument_parser):
+        * Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py: Set http request log path if diagnostic directory
+        is specified.
+        (WebServerBenchmarkRunner.__init__):
+
 2022-03-03  Jonathan Bedard  <[email protected]>
 
         [git-webkit] Handle new PR with old branch name

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py (290810 => 290811)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -400,6 +400,7 @@
 
 class AutoInstall(object):
     DISABLE_ENV_VAR = 'DISABLE_WEBKITCOREPY_AUTOINSTALLER'
+    CA_CERT_PATH_ENV_VAR = 'AUTOINSTALL_CA_CERT_PATH'
 
     directory = None
     index = _default_pypi_index()
@@ -411,7 +412,9 @@
 
     # Rely on our own certificates for PyPi, since we use PyPi to standardize root certificates.
     # This is not needed in Linux platforms.
-    ca_cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')
+    ca_cert_path = os.environ.get(CA_CERT_PATH_ENV_VAR)
+    if not ca_cert_path or not os.path.isfile(ca_cert_path):
+        ca_cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')
 
     _previous_index = None
     _previous_ca_cert_path = None
@@ -537,6 +540,9 @@
         if check:
             cls._verify_index()
 
+        if cls.ca_cert_path:
+            os.environ[cls.CA_CERT_PATH_ENV_VAR] = ca_cert_path
+
         return cls.index
 
     @classmethod

Modified: trunk/Tools/Scripts/webkitpy/__init__.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/__init__.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/__init__.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -54,7 +54,7 @@
     AutoInstall.register(Package('importlib_metadata', Version(1, 7, 0)))
 
 AutoInstall.register(Package('atomicwrites', Version(1, 1, 5)))
-AutoInstall.register(Package('attr', Version(18, 1, 0), pypi_name='attrs'))
+AutoInstall.register(Package('attr', Version(20, 3, 0), pypi_name='attrs'))
 AutoInstall.register(Package('bs4', Version(4, 9, 3), pypi_name='beautifulsoup4'))
 AutoInstall.register(Package('configparser', Version(4, 0, 2)))
 AutoInstall.register(Package('contextlib2', Version(0, 6, 0)))

Modified: trunk/Tools/Scripts/webkitpy/autoinstalled/twisted.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/autoinstalled/twisted.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/autoinstalled/twisted.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -24,5 +24,9 @@
 
 from webkitscmpy import AutoInstall, Package, Version
 
-AutoInstall.register(Package('twisted', Version(15, 5, 0), pypi_name='Twisted'))
+AutoInstall.register(Package('hyperlink', Version(21, 0, 0), pypi_name='hyperlink'))
+AutoInstall.register(Package('constantly', Version(15, 1, 0), pypi_name='constantly'))
+AutoInstall.register(Package('incremental', Version(21, 3, 0), pypi_name='incremental'))
+AutoInstall.register(Package('twisted', Version(20, 3, 0), pypi_name='Twisted'))
+
 sys.modules[__name__] = __import__('twisted')

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -38,6 +38,8 @@
                 self._browser_path = browser_path
                 self._build_dir = os.path.abspath(build_dir) if build_dir else None
                 self._diagnose_dir = os.path.abspath(diagnose_dir) if diagnose_dir else None
+                if self._diagnose_dir:
+                    os.makedirs(self._diagnose_dir, exist_ok=True)
                 self._output_file = output_file
                 self._scale_unit = scale_unit
                 self._show_iteration_values = show_iteration_values

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -41,10 +41,11 @@
     parser.add_argument('web_root')
     parser.add_argument('--port', type=int, default=0)
     parser.add_argument('--interface', default='')
+    parser.add_argument('--log-path', default='/tmp/run-benchmark-http.log')
     args = parser.parse_args()
     web_root = static.File(args.web_root)
     serverControl = ServerControl()
     web_root.putChild('shutdown'.encode('utf-8'), serverControl)
     web_root.putChild('report'.encode('utf-8'), serverControl)
-    reactor.listenTCP(args.port, server.Site(web_root), interface=args.interface)
+    reactor.listenTCP(args.port, server.Site(web_root, logPath=args.log_path), interface=args.interface)
     reactor.run()

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -24,3 +24,6 @@
     @abstractmethod
     def set_device_id(self, device_id):
         pass
+
+    def set_http_log(self, log_path):
+        pass

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -22,16 +22,20 @@
         self._server_process = None
         self._server_port = 0
         self._ip = '127.0.0.1'
+        self._http_log_path = None
         self._ensure_http_server_dependencies()
 
     def serve(self, web_root):
         _log.info('Launching an http server')
         http_server_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "http_server/twisted_http_server.py")
-        interface_args = []
+        extra_args = []
         if self._ip:
-            interface_args.extend(['--interface', self._ip])
+            extra_args.extend(['--interface', self._ip])
+        if self._http_log_path:
+            extra_args.extend(['--log-path', self._http_log_path])
+            _log.info('HTTP requests will be logged to {}'.format(self._http_log_path))
         self._server_port = 0
-        self._server_process = subprocess.Popen([sys.executable, http_server_path, web_root] + interface_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        self._server_process = subprocess.Popen([sys.executable, http_server_path, web_root] + extra_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         max_attempt = 7
         retry_sequence = map(lambda attempt: attempt != max_attempt - 1, range(max_attempt))
         interval = 0.5
@@ -103,6 +107,9 @@
     def set_device_id(self, device_id):
         pass
 
+    def set_http_log(self, log_path):
+        self._http_log_path = log_path
+
     def _ensure_http_server_dependencies(self):
         _log.info('Ensure dependencies of http server is satisfied')
         from webkitpy.autoinstalled import twisted

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -37,6 +37,7 @@
 
 
 def config_argument_parser():
+    diagnose_directory = default_diagnose_dir()
     parser = argparse.ArgumentParser(description='Run browser based performance benchmarks. To run a single benchmark in the recommended way, use run-benchmark --plan. To see the vailable benchmarks, use run-benchmark --list-plans. This script passes through the __XPC variables in its environment to the Safari process.')
     mutual_group = parser.add_mutually_exclusive_group(required=True)
     mutual_group.add_argument('--plan', help='Run a specific benchmark plan (e.g. speedometer, jetstream).')
@@ -51,7 +52,7 @@
     parser.add_argument('--local-copy', help='Path to a local copy of the benchmark (e.g. PerformanceTests/SunSpider/).')
     parser.add_argument('--device-id', default=None, help='Undocumented option for mobile device testing.')
     parser.add_argument('--debug', action='', help='Enable debug logging.')
-    parser.add_argument('--diagnose-directory', dest='diagnose_dir', default=default_diagnose_dir(), help='Directory for storing diagnose information on test failure. Defaults to {}.'.format(default_diagnose_dir()))
+    parser.add_argument('--diagnose-directory', dest='diagnose_dir', default=diagnose_directory, help='Directory for storing diagnose information on test failure. Defaults to {}.'.format(diagnose_directory))
     parser.add_argument('--no-adjust-unit', dest='scale_unit', action='', help="Don't convert to scientific notation.")
     parser.add_argument('--show-iteration-values', dest='show_iteration_values', action='', help="Show the measured value for each iteration in addition to averages.")
 

Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py (290810 => 290811)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py	2022-03-04 02:19:22 UTC (rev 290810)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py	2022-03-04 02:40:59 UTC (rev 290811)
@@ -1,5 +1,6 @@
 import json
 import logging
+import os
 import sys
 
 from webkitcorepy import Timeout
@@ -22,6 +23,8 @@
         self._http_server_driver = HTTPServerDriverFactory.create(platform)
         self._http_server_driver.set_device_id(device_id)
         super(WebServerBenchmarkRunner, self).__init__(plan_file, local_copy, count_override, build_dir, output_file, platform, browser, browser_path, scale_unit, show_iteration_values, device_id, diagnose_dir)
+        if self._diagnose_dir:
+            self._http_server_driver.set_http_log(os.path.join(self._diagnose_dir, 'run-benchmark-http.log'))
 
     def _get_result(self, test_url):
         result = self._browser_driver.add_additional_results(test_url, self._http_server_driver.fetch_result())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to