Title: [222510] trunk/Tools
Revision
222510
Author
[email protected]
Date
2017-09-26 11:58:57 -0700 (Tue, 26 Sep 2017)

Log Message

webkitpy: Notify parent process when a worker is spawned
https://bugs.webkit.org/show_bug.cgi?id=177467
<rdar://problem/34660194>

Reviewed by Daniel Bates.

When we fork the parent process, there may be resources in that process
which workers will take ownership of. Notify ports when a new worker is created
so that these resources can be correctly managed.

* Scripts/webkitpy/common/message_pool.py:
(_MessagePool._start_workers): After all workers are started, notify the caller
that a worker has been created, unless we are running inline, in which case the
parent process is still the worker.
* Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
(LayoutTestRunner._handle_did_spawn_worker): Notify the port that a worker process
has been created.
* Scripts/webkitpy/port/base.py:
(Port.did_spawn_worker): Add function so that ports may manage any
resources created on the parent process but managed by the provided worker.
* Scripts/webkitpy/port/device.py:
(Device.release_worker_resources): Call release_worker_resources on the
platform_device if such a function is defined.
* Scripts/webkitpy/port/ios.py:
(IOSPort.did_spawn_worker): Release any worker resources on the iOS
device object associated with the spawned worker.
* Scripts/webkitpy/test/runner.py:
(Runner.handle): Ignore the did_spawn_worker message during testing.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (222509 => 222510)


--- trunk/Tools/ChangeLog	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/ChangeLog	2017-09-26 18:58:57 UTC (rev 222510)
@@ -1,3 +1,34 @@
+2017-09-26  Jonathan Bedard  <[email protected]>
+
+        webkitpy: Notify parent process when a worker is spawned
+        https://bugs.webkit.org/show_bug.cgi?id=177467
+        <rdar://problem/34660194>
+
+        Reviewed by Daniel Bates.
+
+        When we fork the parent process, there may be resources in that process
+        which workers will take ownership of. Notify ports when a new worker is created
+        so that these resources can be correctly managed.
+
+        * Scripts/webkitpy/common/message_pool.py:
+        (_MessagePool._start_workers): After all workers are started, notify the caller
+        that a worker has been created, unless we are running inline, in which case the
+        parent process is still the worker.
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
+        (LayoutTestRunner._handle_did_spawn_worker): Notify the port that a worker process
+        has been created.
+        * Scripts/webkitpy/port/base.py:
+        (Port.did_spawn_worker): Add function so that ports may manage any
+        resources created on the parent process but managed by the provided worker.
+        * Scripts/webkitpy/port/device.py:
+        (Device.release_worker_resources): Call release_worker_resources on the
+        platform_device if such a function is defined.
+        * Scripts/webkitpy/port/ios.py:
+        (IOSPort.did_spawn_worker): Release any worker resources on the iOS
+        device object associated with the spawned worker.
+        * Scripts/webkitpy/test/runner.py:
+        (Runner.handle): Ignore the did_spawn_worker message during testing.
+
 2017-09-26  Jer Noble  <[email protected]>
 
         Thrown ObjC exception when right clicking on <img> containing mp4 link

Modified: trunk/Tools/Scripts/webkitpy/common/message_pool.py (222509 => 222510)


--- trunk/Tools/Scripts/webkitpy/common/message_pool.py	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/Scripts/webkitpy/common/message_pool.py	2017-09-26 18:58:57 UTC (rev 222510)
@@ -107,6 +107,8 @@
             worker = _Worker(host, self._messages_to_manager, self._messages_to_worker, self._worker_factory, worker_number, self._running_inline, self if self._running_inline else None, self._worker_log_level())
             self._workers.append(worker)
             worker.start()
+            if not self._running_inline:
+                self._caller.handle('did_spawn_worker', worker_number)
             if self._worker_startup_delay_secs:
                 time.sleep(self._worker_startup_delay_secs)
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py (222509 => 222510)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py	2017-09-26 18:58:57 UTC (rev 222510)
@@ -141,6 +141,9 @@
             results_directory = self._filesystem.join(self._results_directory, 'retries')
         return Worker(worker_connection, results_directory, self._options)
 
+    def _handle_did_spawn_worker(self, worker_number):
+        self._port.did_spawn_worker(worker_number)
+
     def _mark_interrupted_tests_as_skipped(self, run_results):
         for test_input in self._test_inputs:
             if test_input.test_name not in run_results.results_by_name:

Modified: trunk/Tools/Scripts/webkitpy/port/base.py (222509 => 222510)


--- trunk/Tools/Scripts/webkitpy/port/base.py	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/Scripts/webkitpy/port/base.py	2017-09-26 18:58:57 UTC (rev 222510)
@@ -1547,3 +1547,8 @@
     def test_expectations_file_position(self):
         # By default baseline search path schema is i.e. port-wk2 -> wk2 -> port -> generic, so port expectations file is at second to last position.
         return 1
+
+    def did_spawn_worker(self, worker_number):
+        # This is overridden by ports that need to do work in the parent process after a worker subprocess is spawned,
+        # such as closing file descriptors that were implicitly cloned to the worker.
+        pass

Modified: trunk/Tools/Scripts/webkitpy/port/device.py (222509 => 222510)


--- trunk/Tools/Scripts/webkitpy/port/device.py	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/Scripts/webkitpy/port/device.py	2017-09-26 18:58:57 UTC (rev 222510)
@@ -68,6 +68,11 @@
             return self.platform_device.symbolicate_crash_log_if_needed(path)
         return self.filesystem.read_text_file(path)
 
+    def release_worker_resources(self):
+        if hasattr(self.platform_device, 'release_worker_resources'):
+            return self.platform_device.release_worker_resources()
+        return None
+
     @property
     def executive(self):
         return self.platform_device.executive

Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (222509 => 222510)


--- trunk/Tools/Scripts/webkitpy/port/ios.py	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py	2017-09-26 18:58:57 UTC (rev 222510)
@@ -208,3 +208,8 @@
                 _log.error('--------------------------------------------------')
 
             raise RuntimeError('Multiple failures when teardown devices')
+
+    def did_spawn_worker(self, worker_number):
+        super(IOSPort, self).did_spawn_worker(worker_number)
+
+        self.target_host(worker_number).release_worker_resources()

Modified: trunk/Tools/Scripts/webkitpy/test/runner.py (222509 => 222510)


--- trunk/Tools/Scripts/webkitpy/test/runner.py	2017-09-26 18:22:40 UTC (rev 222509)
+++ trunk/Tools/Scripts/webkitpy/test/runner.py	2017-09-26 18:58:57 UTC (rev 222510)
@@ -52,7 +52,10 @@
         with message_pool.get(self, self.worker_factory, num_workers) as pool:
             pool.run(('test', test_name) for test_name in test_names)
 
-    def handle(self, message_name, source, test_name, delay=None, failures=None, errors=None):
+    def handle(self, message_name, source, test_name=None, delay=None, failures=None, errors=None):
+        if message_name == 'did_spawn_worker':
+            return
+
         if message_name == 'started_test':
             self.printer.print_started_test(source, test_name)
             return
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to