Title: [290583] trunk/Tools
Revision
290583
Author
[email protected]
Date
2022-02-27 23:07:45 -0800 (Sun, 27 Feb 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 Simon Fraser.

Add support to log http requests during benchmark run for diagnostic purpose.
* 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.
* 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/247861@main

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (290582 => 290583)


--- trunk/Tools/ChangeLog	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/ChangeLog	2022-02-28 07:07:45 UTC (rev 290583)
@@ -1,3 +1,36 @@
+2022-02-27  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 Simon Fraser.
+
+        Add support to log http requests during benchmark run for diagnostic purpose.
+        * 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.
+        * 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-02-27  Jonathan Bedard  <[email protected]>
 
         webkitpy: WebSocket server doesn't support Python 3

Modified: trunk/Tools/Scripts/webkitpy/__init__.py (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/__init__.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/__init__.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/autoinstalled/twisted.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/autoinstalled/twisted.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -24,5 +24,5 @@
 
 from webkitscmpy import AutoInstall, Package, Version
 
-AutoInstall.register(Package('twisted', Version(15, 5, 0), pypi_name='Twisted'))
+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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server_driver.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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 (290582 => 290583)


--- trunk/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py	2022-02-28 05:09:32 UTC (rev 290582)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py	2022-02-28 07:07:45 UTC (rev 290583)
@@ -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