Bug 1265584 - Use ujson where possible for faster metadata update, r=maja_zf draft
authorJames Graham <james@hoppipolla.co.uk>
Thu, 10 May 2018 15:39:14 +0100
changeset 796307 aa4f1a5abcb6d372b9060490db1ee878fec15249
parent 796306 273d5c0d28ce22475fa67bec6d7f1a5b4ca52df5
child 796308 89f6f94a06feaf252025cf8506cd43a5cddaf495
push id110205
push userbmo:james@hoppipolla.co.uk
push dateThu, 17 May 2018 13:42:46 +0000
reviewersmaja_zf
bugs1265584
milestone62.0a1
Bug 1265584 - Use ujson where possible for faster metadata update, r=maja_zf Profiling shows that switching to this library means we no longer spend most of the update time parsing json (vs 80% or so before), making other optimisations worthwhile. This is never used in automation (except wptsync) so availability of the library in the internal pypi isn't a problem. MozReview-Commit-ID: U5gabb5lz8
testing/web-platform/mach_commands.py
testing/web-platform/tests/tools/wptrunner/wptrunner/metadata.py
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -353,17 +353,18 @@ class MachCommands(MachCommandBase):
     def run_wpt(self, **params):
         return self.run_web_platform_tests(**params)
 
     @Command("web-platform-tests-update",
              category="testing",
              parser=create_parser_update)
     def update_web_platform_tests(self, **params):
         self.setup()
-        self.virtualenv_manager.install_pip_package('html5lib==0.99')
+        self.virtualenv_manager.install_pip_package('html5lib==1.0.1')
+        self.virtualenv_manager.install_pip_package('ujson')
         self.virtualenv_manager.install_pip_package('requests')
         wpt_updater = self._spawn(WebPlatformTestsUpdater)
         return wpt_updater.run_update(**params)
 
     @Command("wpt-update",
              category="testing",
              parser=create_parser_update)
     def update_wpt(self, **params):
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/metadata.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/metadata.py
@@ -15,16 +15,23 @@ import testloader
 import wptmanifest
 import wpttest
 from vcs import git
 manifest = None  # Module that will be imported relative to test_root
 manifestitem = None
 
 logger = structuredlog.StructuredLogger("web-platform-tests")
 
+try:
+    import ujson
+except ImportError:
+    pass
+else:
+    reader.json = ujson
+
 
 def load_test_manifests(serve_root, test_paths):
     do_delayed_imports(serve_root)
     manifest_loader = testloader.ManifestLoader(test_paths, False)
     return manifest_loader.load()
 
 
 def update_expected(test_paths, serve_root, log_file_names,